Javascript - Prototype Chain - Hierarchy (Sort of Inheritance)


inheritance doesn't exist in Javascript but an object can be created from a prototype (Composition or linked list ?)

You can then see what was the prototype of the prototype.

Prototype Hierarchy


A function that prints the prototype of the prototype of the ..

var element = document.querySelector("body");
while (element.__proto__ != null) {
    // Print the prototype
    // Element becomes the prototype of the prototype
    element = element.__proto__;

The body element comes from the following chain of prototype.


You can also see the chain of prototype in the dev tool. For instance for Chrome:

Powered by ComboStrap