The splice() method modifies arrays in place:
let arr = [1, 2, 3, 4, 5]
// Remove 2 elements starting at index 1
let removed = arr.splice(1, 2)
console.log(removed) // [2, 3]
console.log(arr) // [1, 4, 5]
// Insert at index 1, remove 0 elements
arr.splice(1, 0, "a", "b")
console.log(arr) // [1, "a", "b", 4, 5]
First argument: start index. Second: how many to remove. Rest: items to insert.