Array reassembly problem?

const List=[["a1","a2"],["b1","b2"]]

List is the data returned from the background. The length is not fixed, and the length of internal elements is not fixed. You want to combine it into the following format:

Program exited with status code of 0.
const res=[ [ "a1", "b1" ], [ "a1", "b2" ], [ "a2", "b1" ], [ "a2", "b2" ] ]

it has been going on for a long time. How can it be realized? Thank you.

Aug.18,2021

const List=[['a1','a2'],['b1','b2']]


var ret = []
function f(i, temp) {
  if (i === List.length) {
    return ret.push([...temp])
  }
  List[i].forEach(n => {
    temp[i] = n
    f(i + 1, temp)
  })
}
f(0, [])
console.log(ret)

the condition that the length is not fixed is relatively broad, and the content of the example is too simple to know what kind of treatment you want to do.


const  = [['a1', 'a2'], ['b1', 'b2', "b3"]]
 = []
for (let  = 0;  < .length; PP) {
    for (let  in []) {
        for (let  =  + 1;  < .length; PP) {
            for (let  in []) {
                .push([[][], [][]])
            }
        }
    }
}
console.log()

this thing is very difficult to understand, so I chose to use Chinese instead of writing notes
before I can explain clearly

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bb67-4ef1d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bb67-4ef1d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?