84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
function F(){} function A(){} F.prototype = A; console.log(new F()) //F {} console.log(new F().prototype) //A {}
为什么new F().prototype 会是 A{}new 不是应该把new F().__proto__指向F.prototype吗继承看的云里雾里是否有什么好的文章推荐呢
ringa_lee
new F().prototype === (new F()).prototype而不是new (F().prototype),如果是new F.prototype,才是new (F.prototype)。new 是把new F().__proto__指向F.prototype,F.prototype = A;你把F.prototype指向了A构造器了,所以是有prototype属性的。new F().prototype === new F().__proto__.prototype
new F().prototype === (new F()).prototype
new (F().prototype)
new F.prototype
new (F.prototype)
new
new F().__proto__
F.prototype
F.prototype = A;
A
prototype
new F().prototype === new F().__proto__.prototype
F.prototype 不就是 A 了么 ..
http://bonsaiden.github.io/Ja...
Chrome 下面和你的打印结果不太一样啊
function F(){} function A(){} F.prototype = A; console.log(new F()) //F {} console.log(new F().prototype) //Object {} console.log(new F().__proto__) //A{}
推荐阅读: http://blog.jobbole.com/66441/
new F().prototype === (new F()).prototype
而不是new (F().prototype)
,如果是new F.prototype
,才是new (F.prototype)
。new
是把new F().__proto__
指向F.prototype
,F.prototype = A;
你把F.prototype
指向了A
构造器了,所以是有prototype
属性的。new F().prototype === new F().__proto__.prototype
F.prototype 不就是 A 了么 ..
http://bonsaiden.github.io/Ja...
Chrome 下面和你的打印结果不太一样啊
推荐阅读: http://blog.jobbole.com/66441/