function insert(arr, item, index) {
var arr1=arr.slice(0);
arr1.splice(index,0,item);
return arr1;
}
Idea:
Use slice(0) to make a new array, then intercept 0 from index, and add item to the position of index.
function insert(arr, item, index) {
var arr1=arr.slice(0);
arr1.splice(index,0,item);
return arr1;
}
Idea:
Use slice(0) to make a new array, then intercept 0 from index, and add item to the position of index.