how to merge arrays in the aaray into one array javascirpt code example
Example 1: javascript merge array
// ES5 version use Array.concat:
let array1 = ["a", "b"]
let array2 = ["1", "2"]
let combinedArray = array1.concat(array2);
// combinedArray == ["a", "b", "1", "2"]
// ES6 version use destructuring:
let array1 = ["a", "b"]
let array2 = ["1", "2"]
let combinedArray = [...array1, ...array2]
// combinedArray == ["a", "b", "1", "2"]
Example 2: js join two arrays
[1,2,3].concat([4,5,6])
// [1,2,3,4,5,6]