Overwrite elements in an array at a given index.
Time complexity: O(n)
Space complexity: O(n)
The array to overwrite elements in
The index to start overwriting elements from
The return value of Array.prototype.splice
Array.prototype.splice
Array
const array = [1, 2, 3, 4, 5];overwrite(array, 1, [8, 9]); // [2, 3]console.log(array); // [1, 8, 9, 4, 5] Copy
const array = [1, 2, 3, 4, 5];overwrite(array, 1, [8, 9]); // [2, 3]console.log(array); // [1, 8, 9, 4, 5]
Overwrite elements in an array at a given index.
Time complexity: O(n)
Space complexity: O(n)