【发布时间】:2021-10-13 02:00:31
【问题描述】:
我有这个数组/对象:
const template = {0: [0, 1, 2, 3, 4, 5], 1: [0, 1, 2, 3, 4, 6]}
// I have the above but happy to convert the below if it helps:
//const templateArr = [[0, 1, 2, 3, 4, 5],[0, 1, 2, 3, 4, 6]]
然后我有一个要映射到该序列的数组:
const myArray = ["Q","W","A","S","Z","X,"E","R","D"] // for example
我打算得到以下结果:
let myResult = [["Q", "W", "A", "S", "Z", "X"],["Q", "W", "A", "S", "Z", "E"]]
所以myArray的所有值都在template设置的位置。
我不确定我是否应该使用.map() 或其他什么...有人能指出我正确的方向吗??
非常感谢!
【问题讨论】:
标签: javascript node.js arrays ecmascript-6