[removed] Store Object as Fixed Value?

后端 未结 3 514
清歌不尽
清歌不尽 2021-01-20 18:51

I\'ve noticed this behavior when writing my JavaScript, and I haven\'t been able to figure out why:

Below is some code to reproduce the behavior in question.

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-20 19:03

    Because both variables reference the same object. Objects are not cloned/copied on variable assignment. You would have to do this yourself.

    JavaScript behaves the same way like any (most) other OO languages in this case.

提交回复
热议问题