Why does this work? Object references in Javascript

后端 未结 3 1214
半阙折子戏
半阙折子戏 2020-12-20 19:27

I\'ve finally been curious enough to find out why javascript does its voodoo magic to learn why not all object references are created equal.

Given the example:

3条回答
  •  甜味超标
    2020-12-20 20:24

    It looks to me that the difference is with b, you're reassigning the variable to a new object/value, while with d, you're modifying the existing object.

提交回复
热议问题