Skip to main content Accessibility Feedback

Arrays

Array.concat()

Merge two or more arrays together. Call concat() on the first array, and pass each array to merge with it in as arguments. It returns a new array.

var sandwiches1 = ['turkey', 'tuna', 'blt'];
var sandwiches2 = ['chicken', 'pb&j'];
var allSandwiches = sandwiches1.concat(sandwiches2);

// logs ['turkey', 'tuna', 'blt', 'chicken', 'pb&j']
console.log(allSandwiches);

Works back to at least IE6.