const textArr=[['a','b','c'],['d','e','f','g'],['h','i']]
const getCombination=(array)=>{
let resultArry=[];
array.forEach((arrItem)=>{
if(resultArry.length===0){
resultArry=arrItem
}else{
const emptyArray=[];
resultArry.forEach((item)=>{
arrItem.forEach((value)=>{
emptyArray.push([...item,value])
})
})
resultArry=emptyArray
}
});
return resultArry;
}
console.log(getCombination(textArr))
js求n个数组的所有组合
于 2023-04-14 16:58:16 首次发布