DEV Community

Cover image for What is prototype in simple words? (Javascipt)
Lawaanu Borthakur
Lawaanu Borthakur

Posted on • Edited on

What is prototype in simple words? (Javascipt)

Each object has private property which holds a link to another object is called its prototype.

Suppose we have an array fruits
let fruits=["Apple", "Orange"];

Now we can use some methods such as concat(),index0f(),join() etc to the fruits array to obtain certain results. But from where these methods came?. They came through prototype of array. i.e:fruits hold a link to array object. You can view it in console by typing Array.prototype in console.

To know how they link with each other you can check by using __proto__ in console which is a getter function that exposes prototype of an object. i.e fruits. __proto__

You will see that fruits.__proto__ values are equivalent to Array.prototype.
Cosole log showing how fruits.__proto__ and Array.prototype are equivalent
References:Prototype

Top comments (0)