Horje
How to Implement Object Oriented Programming in JavaScript ?

The concept of Object Oriented Programming in JavaScript was introduced in ES6. Before ES6 JavaScript did not support the OOPs and it was a completely functional-based programming language everything was done with the help of functions. We can implement the OOPs in ES6 by creating classes and their object instances. Now, after the introduction of ES6, JavaScript become an Object Oriented Programming language as it supports all four basic pillars of OOPs which are inheritance, encapsulation, abstraction, and polymorphism.

Example: The below code example will help you understand how you can implement Object Oriented Programming in JavaScript with the help of a class.

Javascript

class implementOOP{
    name = "GeeksforGeeks";
    getProp(){
        console.log(this.name);
    }
}
const obj = new implementOOP();
obj.getProp();

Output

GeeksforGeeks




Reffered: https://www.geeksforgeeks.org


JavaScript

Related
What are ES6 Modules? What are ES6 Modules?
What is the use of the Event.preventDefault() method in Event Handling in JavaScript ? What is the use of the Event.preventDefault() method in Event Handling in JavaScript ?
What is the use of the Array.some() method in JavaScript ? What is the use of the Array.some() method in JavaScript ?
What is the use of the String.trim() Method in JavaScript ? What is the use of the String.trim() Method in JavaScript ?
What are the Advantages of Using Modules in JavaScript ? What are the Advantages of Using Modules in JavaScript ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
13