Javascript - Prototype Chain - Hierarchy (Sort of Inheritance)

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript) > ECMAScript - Grammar Standard > Javascript - Object

1 - About

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

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

Advertising

3 - Prototype Hierarchy

3.1 - Function

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

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

The body element comes from the following chain of prototype.

3.2 - Devtool

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