本文为阅读博文http://clarkdo.github.io/javascript/2014/08/21/17/后总结而得
①:
f1._proto_==Foo.prototype//true
②:
function Foo() { } ;
var f1 = new Foo();
Foo.prototype.x = "hello";
f1.x //=> hello
Foo.x //=> undefined
注:所有对象会自动读取原型链的属性, 就像那些属性是对象自身定义的.若对象中定义了与原型链中重复的属性,则原型链上的属性会隐藏。
举个栗子:
function foo() { }
f1 = new foo();
f2 = new foo();
foo.prototype.x = "hello";
f1.x => "hello"
f2.x => "hello";
f1.x = "goodbye"; //setting f1.x hides foo.prototype.x
f1.x => "goodbye" //hides "hello" for f1 only
f2.x => "hello"
delete f1.x
f1.x => "hello"; //foo.prototype.x is visible again to f1.