OPP treats the data securely. It is not allowed to flow data freely. It is broken down the problem into small piece of objects to build data.
These are the features of Object-oriented programing in Js:
- Class and Object
- Encapsulation – reduce complexity+ increase reusability
- abstraction – reduce complexity + isolate the impact of changes(hide details)
- inheritance – eliminate redundant code
- Polymorphism – refactor ugly switch/case statement
Object: object has a unique entity that contains properties and methods. we have a real-life example, A car has different characteristics like color, size, model, and type, and performs an action like driving.
Encapsulation: It is the process of wrapping properties and methods in a single unit is known as encapsulation. it is hep to redux the complexity and increase the reusability of class or function.
Abstraction: It is the process of hiding the data is known as abstraction. means when we hide the details information about features in the background.
Inheritance: when we use another object’s properties and method as an object.
Polymorphism: When we have the same methods with different implementations in different classes is called polymorphism.