📌  相关文章
📜  在不改变原始数组的情况下添加到数组 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:25.531000             🧑  作者: Mango

代码示例1
// since we will not be mutating, 
// use const
const arr1 = ['a', 'b', 'c', 'd', 'e'];

const arr2 = [...arr1, 'f']; // ['a', 'b', 'c', 'd', 'e', 'f']
const arr3 = ['z', ...arr1]; // ['z', 'a', 'b', 'c', 'd', 'e']