[javascript] Copy array items into another array

I will add one more "future-proof" reply

In ECMAScript 6, you can use the Spread syntax:

_x000D_
_x000D_
let arr1 = [0, 1, 2];_x000D_
let arr2 = [3, 4, 5];_x000D_
arr1.push(...arr2);_x000D_
_x000D_
console.log(arr1)
_x000D_
_x000D_
_x000D_

Spread syntax is not yet included in all major browsers. For the current compatibility, see this (continuously updated) compatibility table.

You can, however, use spread syntax with Babel.js.

edit:

See Jack Giffin's reply below for more comments on performance. It seems concat is still better and faster than spread operator.