Objec.assign & bug
shallow copy
const log = console.log;
let status = {
r: 0,
x: 0,
y: 0,
w: 0,
h: 0,
};
let obj = {
x: 100,
};
let result = Object.assign({}, status, obj);
// let result = {...status, ...obj};
log(`bug `, result);
chrome browser bug
https://repl.it/@xgqfrms/object-assign-and-browser-bug
chrome bug ???
OK
Deep Clone
-
JSON.parse(JSON.stringify(obj));
-
lodash
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!