1var array1=["A","B","C"];
2
3var array2=["1","2","3","4"];
4
5console.log(array1.flatMap(d => array2.map(v => d + v)))
1function cartesian(...args) {
2 var r = [], max = args.length-1;
3 function helper(arr, i) {
4 for (var j=0, l=args[i].length; j<l; j++) {
5 var a = arr.slice(0); // clone arr
6 a.push(args[i][j]);
7 if (i==max)
8 r.push(a);
9 else
10 helper(a, i+1);
11 }
12 }
13 helper([], 0);
14 return r;
15}
16