OOPS Concept in Javascript

 OOPS Concept in Javascript

In this article we are goanna to see about OOPS concept in Javascript and where we use these. which is most important when you are going to start your career in JavaScript. Please ready and enjoy this article if you want to give any feedback about your experience, we welcome.



Object Oriented Programming Concept

Abstraction: 

Abstraction is a way of creating a simple model of a more complex real-world entities, which contains the only important properties from the perspective of the context of an application.

An abstraction is a way of hiding the implementation details and showing only the functionality to the users. In other words, it ignores the irrelevant details and shows only the required one.

Important point:

We cannot create an instance of Abstract Class.

It reduces the duplication of code.

2. Encapsulation: 

The Encapsulation is a process of binding the data (i.e. variables) 

with the functions acting on that data. It allows us to control the data and validate it. 

To achieve an encapsulation in JavaScript: -

Use var keyword to make data members private. Use setter methods to set the data and getter methods to get that data.

3. Inheritance: 

The inheritance is a mechanism that allows us to create new classes on the basis of already existing classes. It provides flexibility to the child class to reuse the methods and variables of a parent class.

The JavaScript extends keyword is used to create a child class on the basis of a parent class. It facilitates child class to acquire all the properties and behavior of its parent class.

4. Polymorphism: 

The polymorphism is a core concept of an object-oriented paradigm that provides a way to perform a single action in different forms. It provides an ability to call the same method on different JavaScript objects.

As JavaScript is not a type-safe language, we can pass any type of data members with the methods.


Share:

0 comments

Please leave your comments...... Thanks