is javascript an object oriented language 1

is javascript an object oriented language

JavaScript is a prototype based object oriented language, 
  which means it doesnt have classes rather it define 
  behaviors using constructor function and then reuse 
it using the prototype.

Here is what the above code is Doing:
1. We are creating a constructor function called Person.
2. We are adding a property called name to the Person.prototype.
3. We are creating a new object called person1 using the Person constructor.
4. We are adding a property called age to the person1 object.
5. We are creating a new object called person2 using the Person constructor.
6. We are adding a property called age to the person2 object.
7. We are adding a method called sayName to the Person.prototype.
8. We are calling the sayName method on person1 and person2.

Similar Posts