简体   繁体   English

JS对象原型级别和继承复制或参考

[英]JS Objects prototype levels and inheritance Copy or Reference

If we create a object Function or Object, the creation process put reference of prototype prop of Object or Function object to the prototype of the new object! 如果我们创建对象Function或Object,则创建过程会将Object或Function对象的原型道具的引用引用到新对象的原型! or copy all the props in the Obj or Func prototype prop to as the props of the new object? 还是将Obj或Func原型道具中的所有道具复制为新对象的道具?

If it reference the prototype of Obj Func to new obj prototype prop, so if we change one of them prop then it is like we change all of the object created until now and later, get affected! 如果它将Obj Func的原型引用到新的obj原型道具,那么如果我们更改其中一个道具,那么就像我们更改所有创建的对象一样,直到现在或以后,都将受到影响!

If it copy, so it mean it copy a lot of functionality for each object? 如果要复制,那么意味着它为每个对象复制了很多功能? redundancy! 冗余!

So confused and many other related question so lets go step by step, maybe also the question is not correct ones. 如此困惑和许多其他相关的问题就让我们一步一步走,也许也是这个问题不正确。

Thanks in advance, please if there is other such discussion refer me to that so don't waste time. 在此先感谢您,如果还有其他这样的讨论,请转给我,以免浪费时间。

__proto__ VS. __proto__VS。 prototype in JavaScript JavaScript原型

Confusion resolved based on these info 根据这些信息解决了混乱

proto is different than prototype property. 原型不同于原型属性。 only function has prototype. 只有功能具有原型。 proto in a object refer to a prototype of a function, most of the time the function that built that object. 对象中的proto是指函数的原型,大多数情况下是指构建该对象的函数。

The info in above link and diagram on it is the most you need to understand 上面链接和图表中的信息是您最需要了解的信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM