任意的一个函数,都是至关于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
对象添加一个方法