Knowledgize

.toSpliced(start, deleteCount, ...items)

Returns a new array that is a copy of the original array, modified by splicing, without altering the original array.

Examples:

const numbers = [1, 2, 3, 4, 5]; const splicedNumbers = numbers.toSpliced(1, 2, 8, 9); console.log(splicedNumbers); // [1, 8, 9, 4, 5] console.log(numbers); // [1, 2, 3, 4, 5]