不固定个数组,进行一一对应的组合,js将多个数组实现排列组合
var arr = [ ["a", "b"], ["1", "2"], ["d"] ]; var sarr = [ [] ]; for (var i = 0; i < arr.length; i++) { var tarr = []; for (var j = 0; j < sarr.length; j++) for (var k = 0; k < arr[i].length; k++) tarr.push(sarr[j].concat(arr[i][k])); sarr = tarr; } alert(sarr.join("\n"));