JavaScript原型的细微差别

时间:2013-09-29 11:59:05

标签: javascript google-chrome object prototype

在Chrome中,当我这样做时:

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

我在控制台中看到了这一点:

enter image description here

我之前没有看到Object个具有相同名称的两个属性(" a"),我的Chrome出了什么问题?

此处:http://jsfiddle.net/4Zws3/1/

1 个答案:

答案 0 :(得分:2)

一个a是一个实例属性,另一个是原型对象的值。

我实际上是在Chrome中看到这个:

enter image description here

相关问题