Now I am learning JavaScript prototype and __proto__ and find some useful links
__ proto__ VS. JavaScript prototype
How is __proto__ different from the .prototype constructor?
I can get the __proto__ value of the __proto__ object in the following codes in Chrome.
var Foo = function() {} var f = new Foo(); f.__proto__ > Foo {}
However, after setting Foo.prototype.__proto__ to null , __proto__ is undefined .
var Foo = function() {} Foo.prototype = {name: 'cat', age: 10}; Foo.prototype.__proto__ = null; var f = new Foo(); f.__proto__ > undefined
But I can get the value of f.name , which is cat . Here is my understanding, since the value of f.name can be restored, the __proto__ of f should point to Foo.prototype . Why is the value of f.__proto__ equal to undefined ?
javascript google-chrome prototype v8
zangw
source share