First, concat method
Concat (array1,array2…); array.prototype. concat(array1,array2…) ([]).concat(array1,array2…) . Concat can join n arrays without changing the original array
var arr = [[1.2.3], [4.5.6], [7.8.9]]
var newArr = Array.prototype.concat(arr[0],arr[1],arr[2])
console.log(newArr) //(9) [1, 2, 3, 4, 5, 6, 7, 8, 9]
Copy the code
Expansion operator
The expansion operator is a feature of es6 syntax.
let arr = [[1.2.3], [4.5.6], [7.8.9]]
let newArr2 = [...arr[0],... arr[1],... arr[2]]
console.log(newArr2)//(9) [1, 2, 3, 4, 5, 6, 7, 8, 9]
Copy the code
Third, the third method
File loading failed. Please try again later