The splice()
method a combination of the methods that add and remove elements from an array. The splice()
method can remove a number of elements and insert elements into an array. The syntax and the function of the splice()
method is shown below.
arrayname.splice(index, count, elements)
- Removes
count
elements, starting fromindex
position - Adds
elements
at positionindex
- Returns a new array, containing the removed elements