1、利用es6扩展运算符:
function insert(arr, item, index) {
let newArr = [...arr];
newArr.splice(index, 0, item);
return newArr;
} 2、利用slice返回新数组的特性:
function insert(arr, item, index) {
let newArr = arr.slice(0);
newArr.splice(index, 0, item);
return newArr;
} 3、利用concat返回新数组的特性:
function insert(arr, item, index) {
let newArr = arr.concat();
newArr.splice(index, 0, item);
return newArr;
} 
京公网安备 11010502036488号