Assign value not reference in javascript
This question already has an answer here:
你可以使用Object.assign:
var fruit = {
name: "Apple"
};
var vegetable = Object.assign({}, fruit);
vegetable.name = "potatoe";
console.log(fruit);
链接地址: http://www.djcxy.com/p/24762.html
上一篇: JavaScript中的克隆对象
下一篇: 在javascript中分配值不参考