Array.prototype.spliceintermediateconst arr = [1, 2, 4, 5]
arr.splice(2, 0, 3) // insert 3 at index 2
arr // β [1, 2, 3, 4, 5]Pass 0 as deleteCount and provide values to splice() to insert elements without removing any.
Passing 0 as the deleteCount tells splice to delete nothing and only insert elements at the given position.
Challenge: Implement insertAt(arr, index, val) that inserts val at index (shifting existing elements right) and returns the mutated array.
insertAt([1, 2, 3], 1, 99) // β [1, 99, 2, 3]
insertAt([10, 20], 0, 5) // β [5, 10, 20]