var foo = function(){ this.name = "123"; this.length = 20; this.age = 18;
}var bar = Object.create(foo);
bar.__proto__();console.log(bar.name); //fooconsole.log(bar.length); //0console.log(bar.age); //18如上所示代码,根据我的理解,bar.name应该为'123',bar.length应该为20,但是这里只有age的值。
大概理解是name,length属性和Function对象中的name,length冲突,如图:

但是不理解其中的原理和机制,求大神解答。
三国纷争
随时随地看视频慕课网APP
相关分类