📅  最后修改于: 2022-03-11 15:01:14.101000             🧑  作者: Mango
// ES5 version
let flattened = [[1, 2], [3, 4], [5, 6]].reduce(function (acc, curVal) {
return acc.concat(curVal)
}, []);
// ES6 version
let flattened = [[1, 2], [3, 4], [5, 6]].reduce((acc, curVal) => acc.concat(curVal), []);
console.log(flattened); // [1,2,3,4,5,6]