sku数据整合
var attrArr = [{name:'颜色',detail:['红','蓝','黄']},{name:'尺寸',detail:['20cm','30cm']}]
var tmp = [] for (var i in attrArr) { tmp.push(attrArr[i].detail) } 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(...tmp) console.log(allArr) //[['红','20cm'],['红','30cm'],['蓝','20cm'],['蓝','30cm'],['黄','20cm'],['黄','30cm']]