标签:nts cat rip cto art reduce argument console return
let arr = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], ]; 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; }, [[]]); } let allArr =cartesianProductOf(...arr ) console.log(allArr)
标签:nts cat rip cto art reduce argument console return
原文地址:https://www.cnblogs.com/shensss/p/12989084.html