js克隆object
https://stackoverflow.com/questions/6089058/nodejs-how-to-clone-an-object
方法1
function clone(a) {
return JSON.parse(JSON.stringify(a));
}
方法2
let cloned = Object.assign({}, source);
方法3
let cloned = { ... source };
https://stackoverflow.com/questions/6089058/nodejs-how-to-clone-an-object
function clone(a) {
return JSON.parse(JSON.stringify(a));
}
let cloned = Object.assign({}, source);
let cloned = { ... source };