how to add multiple array in single array in node js code example
Example 1: combine two arrays javascript
let arr1 = [0, 1, 2];
let arr2 = [3, 5, 7];
let primes = arr1.concat(arr2);
// > [0, 1, 2, 3, 5, 7]
Example 2: how to add multiple elements to A new array javascript
let vegetables = ['parsnip', 'potato']
let moreVegs = ['celery', 'beetroot']
// Merge the second array into the first one
// Equivalent to vegetables.push('celery', 'beetroot')
Array.prototype.push.apply(vegetables, moreVegs)
console.log(vegetables) // ['parsnip', 'potato', 'celery', 'beetroot']