![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
深拷贝和浅拷贝
A &......
无。。。。。。。。。
展开
-
对象的深拷贝
function deepClone(obj) { let newObj = obj.constructor == Array ? [] : {}; for (let key in obj) { if (typeof obj[key] != 'object') { newObj[key] = obj[key]; } else { ..原创 2021-06-20 21:35:22 · 70 阅读 · 0 评论 -
javascript高级部分02补充----深拷贝和浅拷贝
对象的浅拷贝: var obj1 = { name: 'zhangsan', age: 15 } var obj2 = obj1; obj1.say = function() { console.log('说话'); }; console.log(obj1); console.log(obj2); 把obj1赋值给obj2,会发现当原创 2021-06-16 18:53:45 · 100 阅读 · 0 评论