OneBite.Dev - Coding blog in a bite size

merge multiple array in Javascript

Code snippet on how to merge multiple array in Javascript

  var arr1 = [1, 2, 3];
  var arr2 = [4, 5, 6];
  var arr3 = [7, 8, 9];
  var mergedArrays = arr1.concat(arr2, arr3);

This code shows how to merge multiple arrays into one array using the built-in Javascript function concat(). First, we declare three variables and assign them each with an array of integers. Then, we use the concat() method which takes two or more arrays as arguments and merges them into a single array while maintaining their original order. Finally, we assign the merged array to the variable mergedArrays. This method is easy and efficient to merge multiple arrays into one array.

javascript