Javascript pushing objects into array changes entire array

前端 未结 8 2339
借酒劲吻你
借酒劲吻你 2020-12-03 08:48

I\'m using a specific game making framework but I think the question applies to javascript

I was trying to make a narration script so the player can see \"The orc hi

8条回答
  •  借酒劲吻你
    2020-12-03 09:17

    As mentioned multiple times above, the easiest way of doing this would be making it a string and converting it back to JSON Object.

    this..push(JSON.parse(JSON.stringify()));
    

    Works like a charm.

提交回复
热议问题