花样不要太多。
function insert(arr, item, index) { const newArr = [...arr] newArr.splice(index, 0, item) return newArr }