function cartesianProductOf() {
return Array
.prototype
.reduce
.call(arguments
, function (a
, b
) {
var ret
= [];
a
.forEach(function (a
) {
b
.forEach(function (b
) {
ret
.push(a
.concat([b
]));
});
});
return ret
;
}, [
[]
])
}
console
.log(['a', 'b'], ['c', 'd'])
转载请注明原文地址: https://mac.8miu.com/read-505930.html