Recently I have been playing with javaScript prototype object and came across below example.
function Foo(){
}
Foo.prototype=null;
var fooObj=new Foo();
When I look at the fooObj from developer tools, the __proto__
property points to the global Object's prototype and I can access all properties and function defined in Object's prototype object. which should point to Foo function's prototype object, since I have assigned null to it I was expecting __proto__
will point to null, Pointing __proto__
might make more sense but I want to understand how value is assigned to __proto__
after object creation? what is causing it to point Object's prototype object?
I have seen many questions on prototype and proto but none of them solves my doubts.