OOPS in Javascript

OOPS in Javascript

In this tutorial, we will learn about the OOPS concept in JavaScript.

What is OOPS in Javascript?

OOP is a preagmming paradigm based on the concept of objects.

Paradigm simply means the style of the code, how we write and orgnize cpde


Class is Like a blueprint from which we can creeate new objects based on the rules described in the class

The 4 fundamental principle of oop


Ignoring or hiding details that won't matter, allowing us to get an overview perspective of the thing we're implemenintg,instead of messing with details that don't really matter to our implementation.

Let's say we'ew implmeting a phone for a user to use, they don't need to know whtas going on inside phone, he have to use phone only


Basically means keeping properties and methods private inside the class, so they are not accesible from the outside the clss.

Prevents external code from accidentally manipulating internal properies or state


Child class extends parent class

.Making all properties and methods of a certain class avaiable to a child class, forming a hierarachical reletionship between classes.

Goal is to reuse logic that is comman to both of the classes


A child class can overwrire a method it inherited from a parent class

in simple child class can overwrite a method that is inherited from a parent class

oop in javascript

Objects (instaces) are instantiated from a class,which functions like a blueprint.

this process of creating an instace is called instantiation


Objects are linked to a certain prototype object, so we say that each object has a prototype

In javscript we have something called prototypes and all objects in javascript are linked to a certain prototype object, so we can say that each object has a protptype

the prototype object contains methods and properties that all the objects that are linked to that property can access and use.and this behavioue us useally called prototype inheritance.

 so,the prototypal inheritance means that all objects that are linked to a certain prototype object can use the methods and properties that are defined on that prototype

/so bascailly, object inherit methods and propertires from the prototype which is the reason why this mechanim is called protypal inheriance

3 ways of imlemmeting prototypal inheriance in js

1) Constrctor functions

2) es6 classed

3) Object.create()

Subscribe to our Newsletter

Stay up to date! Get all the latest posts delivered straight to your inbox.

If You Appreciate What We Do Here On TutsCoder, You Should Consider:

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Leave a Comment