美文网首页
Function和Object的关系

Function和Object的关系

作者: Allan要做活神仙 | 来源:发表于2019-04-09 15:07 被阅读0次

2019-04-09-15:05于公司

Pasted Graphic 1.jpg

所以:

Function.__proto__.__proto__ === Object.prototype;//true
Object.__proto__ === Function.prototype;//true

关键点:
Function.__proto__ === function(){}

//①构造器Function的构造器是它自身
Function.constructor=== Function;//true

//②构造器Object的构造器是Function(由此可知所有构造器的constructor都指向Function)
Object.constructor === Function;//true

//③构造器Function的proto是一个特殊的匿名函数function() {}
console.log(Function.proto);//function() {}

//④这个特殊的匿名函数的proto指向Object的prototype原型。
Function.proto.proto === Object.prototype//true

//⑤Object的proto指向Function的prototype,也就是上面③中所述的特殊匿名函数
Object.proto === Function.prototype;//true
Function.prototype === Function.proto;//true

相关文章

网友评论

      本文标题:Function和Object的关系

      本文链接:https://www.haomeiwen.com/subject/zvnbiqtx.html