美文网首页
数组处理

数组处理

作者: 呆桃冲鸭冲鸭 | 来源:发表于2023-04-17 13:12 被阅读0次
    
      const arr = ['a','b']
    
      const num = [
        ["1","2","3","4"],
        ["11","22","33","44"],
      ]
    
      const result = [
        { a:"1",b:"11" },
        { a:"2",b:"22" },
        {  a:"3",b:"33" }
      ]
    
      var ret = []
      for (var i = 0; i < num[0].length; ++i) {
        var obj:any = {}
        obj[arr[0]] = num[0][i]
        obj[arr[1]] = num[1][i]
        ret.push(obj)
      }
      console.log(ret)
    
    result

    相关文章

      网友评论

          本文标题:数组处理

          本文链接:https://www.haomeiwen.com/subject/oqkcjdtx.html