Array.prototype.toSplicedbeginnerconst arr = [1, 2, 3, 4, 5]
arr.toSpliced(1, 2) // β [1, 4, 5]
arr // β [1, 2, 3, 4, 5] (unchanged)Use toSpliced() to remove elements and return a new array, leaving the original intact.
toSpliced is the immutable version of splice. It returns a new array with elements removed or replaced, leaving the original untouched.
Implement removeImmutable which returns a new array with the element at index removed.