~~~
var array = [['a', 'b' ,'c'], ['d', 'e', 'f'], ['g', 'h', 'l']]
var arrayCombination = [];
iteration(array, 0, new Array(0));
console.log(arrayCombination);
function iteration(array, level, former) {
if (array.length == level + 1) {
if (array[level] instanceof Array) {
for (var i = 0; i < array[level].length; i++) {
var temp = former.slice(0);
temp.push(array[level][i]);
arrayCombination.push(temp);
}
} else {
var temp = former.slice(0);
temp.push(array[level]);
arrayCombination.push(temp);
}
} else {
if (array[level] instanceof Array) {
for (var i = 0; i < array[level].length; i++) {
var temp = former.slice(0);
temp.push(array[level][i]);
iteration(array, level + 1, temp);
}
} else {
var temp = former.slice(0);
temp.push(array[level]);
iteration(array, level + 1, temp);
}
}
}
~~~