function insert(arr, item, index) { var temp = arr.slice(0); temp.splice(index,0,item); return temp; /* var temp = [],res = []; temp.push(arr.slice(0,index)); res.push(arr.slice(index)); temp.push(item); return temp.concat(res); */}