var result=[],points=['m1','m2','m3','m4'];
points.forEach((p,index)=>{
result=[...points.slice(index+1,points.length).map(p2=>{return [p,p2]}),...result]
})
console.log(result)
JS实现M*N的不重复组合
最新推荐文章于 2023-02-28 11:13:32 发布
var result=[],points=['m1','m2','m3','m4'];
points.forEach((p,index)=>{
result=[...points.slice(index+1,points.length).map(p2=>{return [p,p2]}),...result]
})
console.log(result)