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
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โ
JS
โ Multi-paradigm High-Level Prototypal Inheritance OOP Scripting Language for full stack Web DevInstance Method
โ Method to Delegate via__proto__
Node Inheritance
โ All Child Delegate methods & properties from ParentPrototype
โ Model blueprint Object to Delegate methods & properties, link via__proto__
, to mimic "classical" OOP InheritanceStatic Method
โ Method attach to Constructor Function (NOT Delegate via__proto__
)Element
โ abstract DOM Interface to Delegate some useful props/methods