创建对象,数组副本的方法

448 阅读1分钟

创建数组副本: const newArr = arr.slice()

创建对象副本: const newObj = Object.assign({},obj)

或者使用对象展开语法 const newObj = {...obj}