OOP is a programming paradigm based on the concept of objects.
Paradigm simply means the style of the code, how we write and organize code
What is Class?
Class is Like a blueprint from which we can create new objects based on the rules described in the class
The 4 fundamental principle of OOPS
Ignoring or hiding details that won't matter, allowing us to get an overview perspective of the thing we're implemenintg,instead of messing with details that don't really matter to our implementation.
Let's say we'ew implmeting a phone for a user to use, they don't need to know whtas going on inside phone, he have to use phone only
Basically means keeping properties and methods private inside the class, so they are not accesible from the outside the clss.
Prevents external code from accidentally manipulating internal properies or state
Child class extends parent class
Making all properties and methods of a certain class available to a child class, forming a hierarchical relationship between classes.
Goal is to reuse logic that is common to both of the classes.
A child class can overwrire a method it inherited from a parent class
in simple child class can overwrite a method that is inherited from a parent class
Objects (instances) are instantiated from a class, which functions like a blueprint, this process of creating an instance is called instantiation
Objects are linked to a certain prototype object, so we say that each object has a prototype
the prototype object contains methods and properties that all the objects that are linked to that property can access and use. and this behavior us usually called prototype inheritance.
so, the prototypal inheritance means that all objects that are linked to a certain prototype object can use the methods and properties that are defined on that prototype
so basically, object inherit methods and properties from the prototype which is the reason why this mechanism is called prototype inheritance
3 ways of imlemmeting prototypal inheriance in js
1) Constructor functions
2) ES6 class