Array.prototype.splicebeginnerconst arr = [1, 2, 3, 4, 5]
arr.splice(1, 2) // β [2, 3] (removed)
arr // β [1, 4, 5]Use splice(start, deleteCount) to remove elements from an array in place.
Array.prototype.splice(start, deleteCount, ...items) mutates the array by removing and/or inserting elements. It returns an array of the removed elements.
Challenge: Implement removeAt(arr, index) that removes 1 element at index and returns the mutated array.
removeAt([1, 2, 3, 4], 1) // β [1, 3, 4]
removeAt([10, 20, 30], 0) // β [20, 30]