What is prototype and prototype chain in JavaScript
Each JavaScript object has a private property which holds a link to another object called its prototype. That prototype object has a prototype of its own, and so on until a object is reached with null as its prototype. null has no prototype and acts as the final link in this prototype chain.
Multiple inheritance with prototypes is referred to as a prototype chain.
To check whether an object has a property defined on itself
and not somewhere on its prototype chain, it is necessary to use the
hasOwnProperty
method which all objects inherit from Object.prototype
.
All functions have a special property named prototype
.
References:
Categories :
JavaScript