.push method can take multiple arguments. You can use the spread operator to pass all the elements of the second array as arguments to
If your browser does not support ECMAScript 6, you can use
>>> a.push.apply(a, b)
Or perhaps, if you think it’s clearer:
Please note that all these solutions will fail with a stack overflow error if array
b is too long (trouble starts at about 100,000 elements, depending on the browser).
If you cannot guarantee that
b is short enough, you should use a standard loop-based technique described in the other answer.