I want to do something like:
var myArray = ["one","two","three"];
document.write(myArray.splice(1,1));
document.write(myArray);
So that it shows first "one,three", and then "one,two,three". I know splice() returns the removed element and changes the array, but is there function to return a new array with the element removed? I tried:
window.mysplice = function(arr,index,howmany){
arr.splice(index,howmany);
return arr;
};
If I try:
var myArray = ["one","two","three"];
document.write(mySplice(myArray,1,1));
document.write(myArray);
It still changes myArray.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…