JavaScript prototyping nuances

In Chrome, when I do this:

 var A = function(){};
 A.prototype =  { a:1,b:2 };
 var aInst = new A;
 aInst.a = 11;
 console.log(aInst);

I see this in the console:

enter image description here

I have not seen Objectwith two properties with the same name (" a") until something is wrong with my Chrome?

Here: http://jsfiddle.net/4Zws3/1/

+4
source share
1 answer

One ais the property of the instance, the other is the value of the prototype object.

I really see this in Chrome:

enter image description here

+2
source

All Articles