Prototypal Inheritance
In JavaScript, objects can inherit properties and methods from other objects. This is done through the prototype chain, allowing one object to use the properties of another.
Javascript info: https://javascript.info/prototype-inheritance
Example
Explanation: Here, the greet
method is added to the Person
prototype, allowing all instances of Person
to share this method without redefining it.
Application: Prototypal inheritance is used to implement inheritance, allowing for more efficient memory usage by sharing methods across instances.