简体   繁体   中英

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! or copy all the props in the Obj or Func prototype prop to as the props of the new object?

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!

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. prototype in 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.

The info in above link and diagram on it is the most you need to understand

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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