concat() Array Method in JavaScript
What do you do when you have two arrays but only need one? You concat them:
var words = [“cockapoo”, “beefalo”]
var moreWords = [“pegacorn”, “schnoodle”]
var allWeirdWords = words.concat(moreWords)
// [ “cockapoo”, “beefalo”, “pegacorn”, “schnoodle” ]
Syntax
firstArray.concat(secondArray);
Remember! The array before the concat() method will be placed before the array inside the parenthesis once they are combined.