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” ]
↓ Here's a great JavaScript course we recommend. Plus, this affiliate banner helps support the site 🙏



Remember! The array before the concat() method will be placed before the array inside the parenthesis once they are combined.

  Tweet It

🕵 Search Results

🔎 Searching...

Sponsored by #native_company# — Learn More
#native_title# #native_desc#