浅拷贝
const info={name:'hello',firend:{age:18}}
const obj=Object.assign({},info)
以上是浅拷贝的一种方式
深拷贝
const info={name:'hello',firend:{age:18}}
const obj=JSON.parse(JSON.stringify(info))
JSON.stringify()实现深拷贝:转为字符串
JSON.parse()还原
借助了json实现的
浅拷贝
const info={name:'hello',firend:{age:18}}
const obj=Object.assign({},info)
以上是浅拷贝的一种方式
深拷贝
const info={name:'hello',firend:{age:18}}
const obj=JSON.parse(JSON.stringify(info))
JSON.stringify()实现深拷贝:转为字符串
JSON.parse()还原
借助了json实现的