Appending an array of items to an array
Suppose you already have some items in an array and you want to append those items to a target array. You can use the concat method to create a new array that is the concatenation of the two arrays and replace the target array with the result:
var items = [ 3, 5, 7 ]; target = target.concat(items); // new instance!
You can avoid replacing the array with a new instance every time you need to append new items to it by using the push method. One thing to note is that push accepts multiple arguments and we can apply the new item array as arguments to push directly:
Array.prototype.push.apply(target, items); // Equivalent to target.push(3, 5, 7) // -- if the items weren't already in an array