📜  循环通过异步 javascript -2 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:41.988000             🧑  作者: Mango

代码示例1
var j = 10;
for (var i = 0; i < j; i++) {
    (function(cntr) {
        // here the value of i was passed into as the argument cntr
        // and will be captured in this function closure so each
        // iteration of the loop can have it's own value
        asynchronousProcess(function() {
            console.log(cntr);
        });
    })(i);
}