// 多个数组进行组合
let Combination = {
recursion(array, depth) {
for (var i = 0; i < array[depth].length; i++) {
this.result[depth] = array[depth][i];
if (depth != array.length - 1) {
this.recursion(array, depth + 1);
} else {
this.results.push([...this.result]);
}
}
},
begin(array) {
this.results = [];
this.result = [];
this.recursion(array, 0);
return this.results;
}
};
网友评论