热搜:m1 nginx 代理 前端

前端开发中的浅拷贝

2024-04-01 09:30:02

前端开发中的浅拷贝 1

// Object.assign
let a = {a: 1, b: 2};
let b = Object.assign({}, a);
// ...
let a = {a: 1, b: 2};
let b = {...a};
// slice
let a = [1, {a: 1}];
let b = a.slice();
// concat
let a = [1, {a: 1}];
let b = [].concat(a);