Im pretty new to node.js, so i’m wondering how to know when all elements are processed in lets say:
["one", "two", "three"].forEach(function(item){
processItem(item, function(result){
console.log(result);
});
});
…now if i want to do something that can only be done when all items are processed, how would i do that?
You can use async module. Simple example: The
The callback function of async.map will when all items are processed. However, in processItem you should be careful, processItem should be something like this: