Javascript函数生成所有排列
如何编写函数来生成此输出。 在javascript中,这种函数的术语是什么? 是javascript递归吗?如何编写函数并生成对象数组Javascript函数生成所有排列,javascript,Javascript,如何编写函数来生成此输出。 在javascript中,这种函数的术语是什么? 是javascript递归吗?如何编写函数并生成对象数组 const letters = ['A', 'B']; const numbers = ['1', '2']; const colors = ['Here is an example of getting all permutations of 3 arrays: let a = [1,2] let b = ['a','b'] let c = ['$','@
const letters = ['A', 'B'];
const numbers = ['1', '2'];
const colors = ['Here is an example of getting all permutations of 3 arrays:
let a = [1,2]
let b = ['a','b']
let c = ['$','@']
a.forEach((ai)=>{
b.forEach((bi)=>{
c.forEach((ci)=>{
console.log(ai + bi + ci)
})
})
})
常量字母=['A','B'];
常量数=['1','2'];
const colors=['以下是获取3个数组的所有排列的示例:
"1a$"
"1a@"
"1b$"
"1b@"
"2a$"
"2a@"
"2b$"
"2b@"
...
导致
因此,您可以轻松地根据自己的使用进行调整。@CBroe从数学上讲,排列不是组合:在前者中,顺序很重要,但在后者中则不重要。OP需要不同的组合,其中字母/数字/颜色的顺序不重要。