Alex Kimeu
By Alex Kimeu

JavaScript Array.splice() Method

JavaScript Array.splice() Method

JavaScript Array splice() method.

This method removes or replaces existing elements in the array. It gets the starting index, count(number of items to remove or replace) and optionally what to replace with. It returns the new array (removed items).

This method modifies the original array.

In case you want to add more elements to the array without removing any, you can provide the count parameter with a value of 0.

NB: Not the best way to add items to an array.