Ivan Chernykh
Ivan Chernykh

Reputation: 42176

Nuances of JavaScript Prototyping

In Chrome when i'm doing this:

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

I see this in console:

enter image description here

I didn't see Objects with two properties with the same name ("a") before, something wrong with my Chrome?

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

Upvotes: 4

Views: 214

Answers (1)

Matt Zeunert
Matt Zeunert

Reputation: 16571

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

I'm actually seeing this in Chrome:

enter image description here

Upvotes: 2

Related Questions