思维导图
- 原型链中最终的构造器函数是function Function(),
- 原型链中最终的原型是Object prototype
- new Foo()
function Foo() {};
var foo = new Foo();
Foo.prototype.constructor === Foo//output:true
foo.constructor === Foo //output:true
foo.__proto__ === Foo.prototype //output:true
foo.__proto__.constructor === Foo //output:true
例子
Foo.prototype.label = "crli";
foo.label === "crli"; //output: true
Foo.label === undefined; //output: true
function Foo() {};
var foo = new Foo();
例子
Foo.__proto__.xx = "aa";
Foo.__proto__ === Function.prototype//output: true
Foo.xx === aa; //output: true
foo.xx === undefined;//output: true
Function.prototype.__proto__ === Object.prototype
- new Object()
var foo = new Object();
foo.__proto__ === Object.prototype //output:true
Object.prototype.__proto__ === null //output:true