splice() method which removes elements from the array and as well as adds
elements to the array. Syntax of splice() method is as given below:
- index It specifies the index position from
where to add/remove elements and it is mandatory for splice() method
- howmany It is also mandatory and it specifies
that how many elements to be removed.
- element1...N It is optional and represents
the element to be added.
splice() example as follows:
var arr = new Array(5);
document.write("<b>Original Array is </b>=>"+arr+"<br>");
Example of implementing splice() method on array
Output of this example is as follows:
Download Sample Source Code