Now I am learning JavaScript prototype
and __proto__
, and find several useful links
__proto__ VS. prototype in JavaScript
How does __proto__ differ from constructor.prototype?
I can get the value of __proto__
of object f
in the following codes under Chrome.
var Foo = function() {}
var f = new Foo();
f.__proto__
> Foo {}
However, after setting the Foo.prototype.__proto__
to null
, the value of __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 f.name
can be retrievable, the __proto__
of object f
should point to Foo.prototype
. Why the value of f.__proto__
is undefined
?