var data = [
['A1','A2'],
['B1','B2','B3'],
['C1','C2'],
['D1','D2','D3'],
['E1','E2','E3'],
];
function descartes(arr) {
var result = [], point = [], count = 1;
for (var i = 0; i < arr.length; i++) {
point.push(arr[i].length);
count *= arr[i].length;
}
for (var i = 0; i < count; i++) {
var _zb = [], _tmp = i;
for (var j = point.length - 1; j > -1; j--) {
_zb[j] = _tmp % point[j];
_tmp = parseInt(_tmp / point[j]);
}
var _item = [];
for (var k = 0; k < _zb.length; k++) {
_item[k] = arr[k][_zb[k]];
}
result.push(_item);
}
return result;
}
console.log(descartes(data));