Skip to main content

Prototypal Inheritance โ†” Link for all Object to their Prototype, to mimic Inheritance access to Method & props

aka Prototypal, Delegate, Delegation, Prototype-based

JavaScript does not have real "Classical" classes & instead implements Prototypal Inheritance to emulate equivalent functionality

JS is Prototype-basedObject-Oriented w/o old-school OOP Classes

Prototype Chainโ€‹

Series of links to connect Object to Prototype; to mimic Inheritance

Constructor Function (function to programmatically create Object (& link via __proto__ after Instantiation with new))

class (JS Keyword to declare Class (as Syntactic Sugar over Constructor Function) )

Object.create() (Static Method to manually link Object to another as __proto__ )

classโ€‹

JS Keyword to declare Class (as Syntactic Sugar over Constructor Function)

Static Methodโ€‹

Method attach to Constructor Function (NOT Delegate via __proto__)

Almost everything in JS (excl Primitives) is an Object

image

Prototypes are like blueprints to contain all Object's properties & methods

All Instance created from Prototype Delegate Prototype's Methods

Prototypeโ€‹

Model blueprint Object to Delegate methods & properties, link via __proto__, to mimic "classical" OOP Inheritance

Methods don't need to be copied to child objects - boosting code performance

Referencesโ€‹

  1. JS โ†” Multi-paradigm High-Level Prototypal Inheritance OOP Scripting Language for full stack Web Dev

  2. Instance Method โ†” Method to Delegate via __proto__

  3. Node Inheritance โ†” All Child Delegate methods & properties from Parent

  4. Prototype โ†” Model blueprint Object to Delegate methods & properties, link via __proto__, to mimic "classical" OOP Inheritance

  5. Static Method โ†” Method attach to Constructor Function (NOT Delegate via __proto__)

  6. Element โ†” abstract DOM Interface to Delegate some useful props/methods