The splice()
method can
modify an array by removing,
replacing or inserting elements.
It returns an array
of the removed its elements.
In the example given above,
starting from index 1
,
splice
removes 3 elements
from the numbers
array.
The variable removedNumbers
stores the removed elements.
In the example given above,
it removes the element "mango"
at index 2
and
inserts the element
"kiwi"
in its place.
In the example given above,
it adds the element "kiwi"
at index 2
without
removing any element.