I have just written this snippet of code.
function Point(x,y){
this.x = x;
this.y = y;
}
var myPoint = new Point(4,5);
console.log(myPoint.__proto__ === Point.prototype);
console.log(Point.__proto__ === Function.prototype);
console.log(Function.__proto__ === Object.prototype);
The first two expressions returns true but the 3rd expression returns false.I am not sure why it returns false, because as per the below image, it is supposed to return true.
In the image you can notice Function.prototype's __ proto __ property point to Object.prototype.
Could anyone please clear my concepts?
In the image you can notice Function.prototype's __ proto __ property point to Object.prototype.
But that is not what you tested! You tested Function.__proto__
, which is actually equal to Function.prototype
. Try this instead:
console.log(Function.prototype.__proto__ === Object.prototype);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With