Master AI & Build your First Coding Portfolio with SkillReactor | Sign Up Now

Lesson 7 - Basic Array Operations

7.4 Concat

Like strings, JavaScript also contains a function concat() to combine multiple arrays. Follow the example below:

let fruits1 = ['Apple', 'Mango'];
let fruits2 = ['Orange', 'Grapes'];
console.log(fruits1.concat(fruits2));

In the above example, we combined the arrays fruits1 and fruits2. The output will contain all the elements of the arrays fruits1 and fruits2.