array.push.apply()
该方法会改变原数组
var arr1 = [1,2];
var arr2 = ["aa","as"];
arr1.push.apply(arr1, arr2);
console.log(arr1); //[1, 2, "aa", "as"]
console.log(arr2); //["aa", "as"]
n个数组合并成一个数组
var obj = {
1: [1,2,4,3],
2: [2,3,4,5],
3: [4,5,6]
}
Object.values(obj).reduce((a,b) => [...a, ...b], [])
数组排列组合
arr = [
['a', 'b'],
['1', '2'],
['x', 'y'],
]
results = [];
result = [];
doExchange(arr, 0);
function doExchange(arr, index){
for (var i = 0; i<arr[index].length; i++) {
result[index] = arr[index][i];
if (index != arr.length - 1) {
doExchange(arr, index + 1)
} else {
results.push(result.join(','))
}
}
}
console.log( results);
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。