Member-only story
Object Oriented Programming in JavaScript
JavaScript is a prototype-based programming style of object-oriented programming in which classes are not present.
It can support OOP because it supports inheritance through prototyping as well as properties and methods.
Object-Oriented Programming in JavaScript is known as prototype-based programming
We will learn about below
- Classes in JavaScript
- Constructor in JavaScript
- Properties in JavaScript
- Object of JavaScript classes
- Method of Javascript classes
1. Creating Class in JavaScript
the following syntax is used for declaring a class in JavaScript:
function Emp() {
alert('Emp instantiated');
}Here Emp can act as a class in JavaScript.
The body of Emp acts as a constructor and is called as soon as we create an object of the class.
2. Creating Objects of Emp Class
Using the following syntax we can create an object of the Emp class:
var Emp1 = new Emp();As soon as we create an object of the Emp class the constructor will be called.
Here the above function Emp would be treated as a class in JavaScript.









