Tag Archives: Javascript Splice array method

Javascript Splice array method

Splice Changes the content of an array, adding new elements while removing old elements. Syntax array.splice(index, howMany[, element1[, …[, elementN]]]) Example // assumes a print function is defined var myFish = [“angel”, “clown”, “mandarin”, “surgeon”]; print(“myFish: ” + myFish); var removed = myFish.splice(2, 0, “drum”); print(“After adding 1: ” + myFish); print(“removed is: ” + […]