简体   繁体   中英

Parent is Inheriting from Child - JavaScript

浏览器控制台截图

Really confused here, checkout the image above. Why the parent a is inheriting something that i defined for its child?

in javascript when you assign an object variable as a variable it is a reference to a single object just like arrays. so instead of being a copy of the object it is pointing to the original object in memory. this means that both a and b are pointing to the same object in memory. any action taken on one variable will effect the other since they are pointing to the same instance of the object.

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