__proto__VS。 JavaScript原型

跟風遠走 提交于 2020-04-28 02:19:12

问题:

This figure again shows that every object has a prototype. 该图再次显示每个对象都有一个原型。 Constructor function Foo also has its own __proto__ which is Function.prototype, and which in turn also references via its __proto__ property again to the Object.prototype. 构造函数Foo还具有自己的__proto__ ,即Function.prototype,而该__proto__又通过其__proto__属性再次引用了Object.prototype。 Thus, repeat, Foo.prototype is just an explicit property of Foo which refers to the prototype of b and c objects. 因此,重复一遍,Foo.prototype只是Foo的显式属性,它引用b和c对象的原型。

var b = new Foo(20);
var c = new Foo(30);

What are the differences between __proto__ and prototype ? __proto__prototype什么区别?

在此处输入图片说明

The figure was taken from dmitrysoshnikov.com . 该图取自dmitrysoshnikov.com


解决方案:

参考一: https://stackoom.com/question/fmyl/proto-VS-JavaScript原型
参考二: https://oldbug.net/q/fmyl/proto-VS-prototype-in-JavaScript
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!