var recursionSub = function(list, count, array, ind, start, indexs) {
start++;
if (start > count - 1) {
return;
}
if (start == 0) {
indexs = new Array(array.length);
}
for (indexs[start] = 0; indexs[start] < array[start].length; indexs[start]++) {
recursionSub(list, count, array, 0, start, indexs);
if (start == count - 1) {
var temp = new Array(count);
for (var i = count - 1; i >= 0; i--) {
temp[start - i] = array[start - i][indexs[start - i]];
}
list.push(temp);
}
}
}
var temp = [
["S1", "S2", "S3"],
["H4", "H5"],
["D6", "D7", "D8"]
];
var list = [];
recursionSub(list, temp.length, temp, 0, -1);
for (var i = 0; i < list.length; i++) {
console.log(list[i]);
}io