Let's say I have the following:
const arr = [1,2,3]
const newArr = [...arr].splice(0, 0, 'test')
console.log(newArr)
This won't work and will return an empty array. However, if I move the splice part to a new line, the code works as expected:
const arr = [1,2,3]
const newArr = [...arr]
newArr.splice(0, 0, 'test')
console.log(newArr)