Modifying a copy of a JavaScript object is causing the original object to change

前端 未结 5 1402
野趣味
野趣味 2020-11-22 05:06

I am copying myObj to tempMyObj

var tempMyObj = myObj;

tempMyObj.entity is an array of objects. I am

5条回答
  •  轮回少年
    2020-11-22 05:37

    Try using the create() method like as mentioned below.

    var tempMyObj = Object.create(myObj);
    

    This will solve the issue.

提交回复
热议问题