Why doesn't Array.push.apply work? Why doesn't Array.push.apply work? javascript javascript

Why doesn't Array.push.apply work?


You can also use [].push.apply(a, b) for shorter notation.


The current version of JS allows you to unpack an array into the arguments.

var a = [1, 2, 3, 4, 5,];var b = [6, 7, 8, 9];a.push(...b); //[1, 2, 3, 4, 5, 6, 7, 8, 9];