Live2D

js实现简单sku变体组合算法

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)

  

posted @ 2020-05-29 18:40  sss申  阅读(1451)  评论(0编辑  收藏  举报