concat arrays with + in javascript code example
Example 1: concatenate javascript array
const fruits = ['apple', 'orange', 'banana'];
const joinedFruits = fruits.join();
console.log(joinedFruits); // apple,orange,banana
Example 2: join two arrays javascript
// using push and apply to return the same array
const arr1 = ['a', 'b'];
const arr2 = ['c', 'd'];
arr1.push.apply(arr1, arr2);
console.log(arr1) // ['a', 'b', 'c', 'd']