排列组合的递归实现
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title></title> 6 </head> 7 <body> 8 <script> 9 10 var d = ["a","b","c"]; 11 var arr = []; 12 kk(""); 13 14 function kk(dd){ 15 if(dd.length == 4){ 16 arr.push(dd) 17 return; 18 } 19 for(var l = 0;l<3;l++){ 20 kk(dd+d[l]) 21 } 22 } 23 console.log(arr) 24 </script> 25 </body> 26 </html>