-
1. JavaScript函數(shù)是引用類型(對(duì)象類型), 所以Function函數(shù)也是對(duì)象
"Function構(gòu)造函數(shù)"也是一個(gè)對(duì)象, 所以也有
__proto__
屬性-
"Function構(gòu)造函數(shù)"
__proto__
屬性指向"Function原型對(duì)象"console.log(Function.__proto__); // ? () { [native code] } console.log(Function.__proto__ === Function.prototype); // true
-
2. JavaScript中還有一個(gè)系統(tǒng)提供的構(gòu)造函數(shù)叫做Object, 只要是函數(shù)都是"Function構(gòu)造函數(shù)"的實(shí)例對(duì)象
console.log(Object); // ? Object() { [native code] }
-
只要是對(duì)象就有
__proto__
屬性, 所以"Object構(gòu)造函數(shù)"也有__proto__
屬性, "Object構(gòu)造函數(shù)"的__proto__
屬性指向"Function原型對(duì)象"console.log(Object.__proto__); // ? () { [native code] } console.log(Object.__proto__ === Function.prototype); // true
-
-
3. JavaScript中只要是"構(gòu)造函數(shù)"就有prototype屬性, "Object構(gòu)造函數(shù)"的prototype屬性指向"Object原型對(duì)象"
console.log(Object.prototype);
-
4. JavaScript中只要是"原型對(duì)象"就有constructor屬性, "Object原型對(duì)象"中的constructor屬性指向它對(duì)應(yīng)的Object構(gòu)造函數(shù)
console.log(Object.prototype.constructor); // ? Object() { [native code] } console.log(Object.prototype.constructor === Object); // true
-
5. 只要是對(duì)象就有
__proto__
屬性, 所以"Object原型對(duì)象"也有__proto__
屬性, "Object原型對(duì)象"的__proto__
屬性指向NULLconsole.log(Object.prototype.__proto__); // null