So what is array.splice()?
ArrayName.splice(start, how_many_items_to_remove, item1, item2, ...);
- The first parameter 'start' is the index to start.
- The second parameter 'how_many_items_to_remove' it's how many items to be removed from an array.
- The third parameter is what values to add to the array.
For Example:
let cars = ['Volvo','BMW','Toyota', 'Audi']; let result = cars.splice(2,1,'Mercedes'); console.log(result); // ['Volvo', 'BMW', 'Mercedes', 'Audi']