【发布时间】:2013-04-29 20:55:05
【问题描述】:
如果你有以下代码:
var asyncConfig = {};
var a, b;
for(var i = 0; i < someValue; i++) {
// do something with a
// do something with b
asyncConfig[i] = function(callback) {
func(a, b, callback); // func is async
}
}
// Include some more parallel or series functions to asyncConfig
async.auto(asyncConfig);
- 如何将变量
a和b的值传递给func,以便在for循环之后执行async.auto(asyncConfig)时,保留a和b的上下文?
(a 和 b 的不同上下文对于 func 的每次执行。)
提前谢谢你!
【问题讨论】:
标签: javascript node.js asynchronous