Pavel Terkin,
вариант
Sweet,
https://javascript.ru/forum/misc/194...tml#post117263
<script>
function combinator(matrix){
return matrix.reduceRight(function(combination, x){
var result = [];
x.forEach(function(a){
combination.forEach(function(b){
result.push( [ a ].concat( b ) );
});
});
return result;
});
};
document.write(
combinator( [[1,2,4], [1,2,4]] ).join("<br>")
);
</script>