Inheritance
Definition
A mechanism where a class (child) derives properties and methods from another class (parent). In JavaScript, inheritance is achieved through the prototype chain or the `extends` keyword with ES6 classes.
Code Example
Learn More
Related Terms
Every JavaScript object has a hidden internal property called [[Prototype]] that links to another object. When a property is accessed on an object and not found, JavaScript walks up the prototype chain to find it. This is the basis of JavaScript's inheritance model.
ClassES6 syntactic sugar over JavaScript's prototype-based inheritance. Classes provide a cleaner way to create objects and implement inheritance using extends and super.
PolymorphismThe ability for different classes to respond to the same method call in different ways. In JavaScript, polymorphism is achieved through method overriding in subclasses and duck typing.