【发布时间】:2016-05-17 10:40:21
【问题描述】:
async.each 是否作为异步数组迭代工作?
async.eachSeries 是否作为同步数组迭代工作?(实际上是在等待响应)
我问这些是因为两者都有回调,但 async.each 的工作方式就像异步数组迭代 ex:
//This is traditional way to iterate an array with callback functions in node.js
//Is this same with async.each ? i want to know it actually.
for (var i = 0; i < data.length; i++) {
(function (i) {
request(data[i],function(body){
console.log(body)
});
})(i);
//if this codes and async.each are doing same things ,
//i know that async gives me an aert when all finished thats the difference.
【问题讨论】:
标签: javascript node.js asynchronous