Object Oriented Programming | Javascript Hindi Course For Beginners ( 2023 ) #14
Object-Oriented Programming (OOP) is a programming paradigm that focuses on the use of objects to represent real-world concepts and entities.
Four principles of object-oriented programming
- Encapsulation: Encapsulation refers to the process of hiding the internal details of an object from the outside world.Object’s state and behaviour are not accessible or modifiable by code outside of the object. This helps to ensure that the object's state remains consistent and that its behaviour is reliable, which can help to reduce errors and improve the maintainability of the code.
- Abstraction: Abstraction involves simplifying complex systems by breaking them down into smaller, more manageable parts.
- Inheritance: Inheritance is the mechanism by which one class can inherit properties and behaviours from another class. In OOP, inheritance is used to create new classes that are based on existing classes, thereby reducing code duplication and improving code reuse.
- Polymorphism: Polymorphism allows objects of different classes to be treated as if they were of the same class.polymorphism is achieved through method overriding and method overloading.Method overriding involves creating a new implementation of a method in a subclass that overrides the implementation in the superclass. Method overloading involves creating multiple methods with the same name but different parameters, allowing the same method name to be used with different types of objects.
Constructor Function
Constructor function was old way of doing Oops (Object oriented programmings). Using this function we create object and using prototypes we assign different functionality to that object.
Proptype
the
prototype
property is used to add properties and methods to an object constructor function. The prototype object is shared among all instances created using the constructor function.Class
Classes were introduced in the ECMAScript 6 (ES6) version to provide a more structured and object-oriented approach to programming. A class in JavaScript is a blueprint for creating objects that encapsulate data and behaviour.
Classes in JavaScript provide a convenient way to create objects with a consistent structure and behaviour. They also enable inheritance and polymorphism, which allows for more flexible and reusable code.
Inheritance
Inheritance is a fundamental concept in object-oriented programming that allows one class to inherit properties and methods from another class. In JavaScript, inheritance is implemented using prototype chaining.
Encapsulation
Encapsulation refers to the process of hiding the internal details of an object from the outside world.Object’s state and behaviour are not accessible or modifiable by code outside of the object. This helps to ensure that the object's state remains consistent and that its behaviour is reliable, which can help to reduce errors and improve the maintainability of the code.
Polymorphism
Polymorphism allows objects of different classes to be treated as if they were of the same class.polymorphism is achieved through method overriding and method overloading.Method overriding involves creating a new implementation of a method in a subclass that overrides the implementation in the superclass. Method overloading involves creating multiple methods with the same name but different parameters, allowing the same method name to be used with different types of objects.
A static method or property is one that belongs to the class itself, rather than to any particular instance of the class. This means that you can call a static method or access a static property directly on the class, without needing to create an instance of the class first.
Note that you cannot access static members on instances of the class:
"Object Oriented Programming | Javascript Hindi Course for Beginners (2023) #14" is a tutorial video that teaches the basics of OOP in Javascript, with a focus on encapsulation, inheritance, and polymorphism. Complete Notes of JS - https://dosomecoding.com/courses/javascript/javascript-hindi-course-for-beginners HTML Course https://www.youtube.com/playlist?list=PLPppPPmk0i3gL2isb9Kr1GvTM8id2gdtY CSS Course https://www.youtube.com/playlist?list=PLPppPPmk0i3gWK5TVILnKSvuc9Fc15sbH Html and CSS practice Projects https://www.youtube.com/playlist?list=PLPppPPmk0i3hZCNmbVtcP1hlwDKOdUFX9 Javascript Course https://www.youtube.com/playlist?list=PLPppPPmk0i3gZCY8JZ0H5oykFGevvNzNS Linkedin - https://linkedin.com/in/anshuopinion Telegram Channel - https://telegram.me/dosomecodinghelp Instagram - https://instagram.com/dosomecoding Github - https://github.com/anshuopinion