.splice() returns an array of the elements that have been removed out of the array, Since .splice(n, 0, ...), it doesn’t remove anything, but it still has to return an array, so it returns an empty one.
Maybe you intend to return newarr2 after splicing?
splice can take as many arguments as needed and will add all of them in the array
the difference between the two is given by the spread operator. a1 is an array, and it is the array that is added to the other array. if you use the spread operator this will unpack the array, and it works as if each element of the array is an argument for the splice method: in this way the splice method is adding the elements of the array to the other array (instead of a single array)