__proto__和prototype

每个对象都有属性__proto__,指向该对象的构造函数的原型对象[也就是prototype]。
还有prototype,指向该方法的原型对象

①__proto__和constructor属性是对象所独有的;
② prototype属性是函数所独有的,因为函数也是一种对象,所以函数也拥有proto和constructor属性。

 let o1 = new Object();
 console.log((o1.__proto__ === Object.prototype))//true
 
 console.log(Object.prototype)//{}
 console.log(Object.prototype.__proto__)//null
 console.log(Object.prototype.constructor)//[Function: Object]

 let o2 = {}
 console.log(o2.prototype)//undefined
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容