Javascript pushing objects into array changes entire array

前端 未结 8 2363
借酒劲吻你
借酒劲吻你 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:05

    This solution also work on the object containing nested keys.

    Before pushing, stringify the obj by

    JSON.stringify(obj)
    

    And when you are using, parse by

    JSON.parse(obj);
    

提交回复
热议问题