Arrayinarray=[];
let options = driver.findElements(By.css("[section='trim'] select"));
options.then(swap=>{
swap.map((key)=>{
var s=key.findElements(By.css("option"));
s.then(mt=>{
Arrayinarray.push(mt)
})
})
});
这是我的 Selenium 代码。
我必须以正确的顺序获取数组的每个元素
例如。
var Arrayinarray=[[1,2,3],[4,5,6,5],[7,8,9],[1,6,3],[1,5,7][1,2,2],[7,2,9,3]];
预期输出:
1471117 1471112 1471119 1471113 1471127 1471122
1471129 1471123 1471127 1471122 1471129 1471123
...
我必须排列这个多维数组的组合。我放置了许多 for
循环和 map
函数。然而,它不起作用。
最佳答案
您可以采用迭代方法,收集所有零件数组并使用最终数组来获取数字。
var values = [[1, 2, 3], [4, 5, 6, 5], [7, 8, 9], [1, 6, 3], [1, 5, 7], [1, 2, 2], [7, 2, 9, 3]],
result = values
.reduce((a, b) => a.reduce((r, v) => r.concat(b.map(w => [].concat(v, w))), []))
.map(s => +s.join(''));
console.log(result);
.as-console-wrapper { max-height: 100% !important; top: 0; }
关于Javascript - 处理多维数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48341131/