任意的一個函數,都是至關於Function
的實例。相似於{}
與new Object()
的關係。函數
函數應該有什麼屬性?__proto__
spa
prototype
屬性Function
Function.prototype
Function.prototype
繼承自Object.prototype
__proto__
屬性,原型對象的__proto__
屬性指向Object
原型對象Object.prototype
的原型是null
Object
構造函數是函數,一切函數在Function
構造函數面前都是對象prototype
Object
構造函數是Function
構造函數的實例對象Object
做爲對象是繼承自Funtion.prototype
的,又Function.prototype
繼承自Object.prototype
Function是構造函數,全部的函數是Function構造函數的實例,構造函數也是函數,因此全部的構造函數也是Function構造函數的實例,因此Function便是構造函數,也是實例,因此Function是本身的構造函數,是它本身創造了本身
code
因爲Function
是本身的構造函數也是本身的實例,因此Function
構造函數中既有prototype
屬性也有__proto__
屬性。對象
Function
構造函數的prototype
屬性指向Function.prototype
原型對象,Function.prototype
原型對象的原型是Object
原型對象Object
構造函數的構造函數是Function
構造函數,也就是Function
構造函數實例化了Object
構造函數,因此Object
構造函數做爲對象來講,它自己也有__proto__
屬性,指向了Function.prototype
原型對象(曲線)Function
構造函數(函數的老大)的原型對象都要繼承自Object
原型對象;最牛的Object
構造函數(對象的老大)都是由Function
構造函數建立出來的Object.prototype
Function.prototype
Function.prototype
繼承自Object.prototype
,因此任何函數的老祖宗也是Object.prototype
(此條結論是推導出來的,主要記上面兩條結論)Object.prototype
對象添加一個方法Function.prototype
對象添加一個方法