经典全排列改进版(回溯递归) function pailie (arr) { let res = [] const dfs = (path,index) => { if(path.length == arr.length) { res.push(path) return } arr.forEach((n,i) => { n.forEach(k => { if(i == index) { dfs(path + k,index+1) } }) }) } dfs("",0) return res }