Objec.assign bug All In One
Objec.assign bug All In One
shallow copy /
浅拷贝
Error ❌
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);
OK ✅
chrome browser bug
https://repl.it/@xgqfrms/object-assign-and-browser-bug
chrome bug ???
OK
Deep Clone
-
JSON.parse(JSON.stringify(obj));
-
lodash
refs
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/12155240.html
未经授权禁止转载,违者必究!