Pavel Terkin,
<script>
function gn(a) {
if (2 > a.length) return a[0];
for (var d = [], e = a.shift(), f = a.shift(), b = 0; b < e.length; b++)
for (var c = 0; c < f.length; c++) d.push([].concat(e[b],f[c]));
a.unshift(d);
return gn(a)
};
document.write(JSON.stringify(gn( [[1,2,3], [4,5,6],[7,8,9]] )))
</script>