JavaScript Array splice()
JavaScript Array splice()
The splice() method is used to add and/or remove array elements. It will overwrite the original array.
Syntax:-
Its syntax is- array.splice(index, numbers, item1, ....., itemX)
Return:-
Its return is:- a new array containing the removed items.
Further Explanation:-
Parameter | Description |
index | Required. The position to add/remove items. |
numbers | Optional. The number of items to be removed. |
item1, ..., itemX | Optional. New elements to be added. |