【问题标题】:node.js: using foreach with a multidimensional arraynode.js:将 foreach 与多维数组一起使用
【发布时间】:2014-07-04 12:06:46
【问题描述】:

我试图用数组本身的每一行调用一个函数。到目前为止,我的代码总是出错,我似乎无法理顺。有人能告诉我怎么做吗? 输出应该是“['a', 4], ['b', 1], ['j', 2], ['c', 3], ['d', 5], ['e', 2],['f',2],['g',6]"。

var testqueue = [['a', 4], ['b', 1], ['j', 2], ['c', 3], ['d', 5], ['e', 2], ['f', 2], ['g', 6]];

function test(cb){

testqueue.foreach(function(item){
console.log(item);
});
cb('done');
}

test(function(result){
console.log(result);
});

【问题讨论】:

    标签: node.js multidimensional-array foreach


    【解决方案1】:

    对不起,这只是一个错字:(

    它应该是 forEach(大写 E)并且一切正常。

    【讨论】:

      猜你喜欢
      • 2014-03-06
      • 2016-12-20
      • 1970-01-01
      • 2016-04-11
      • 2012-12-13
      • 2013-01-09
      • 1970-01-01
      • 2021-12-14
      • 1970-01-01
      相关资源
      最近更新 更多