Can I count on nodeIDs mapping is completed every time doSomething() is called?
nodeIDs = $.map(nodeIDs, function(n){ return n.match(/\\d+$/); }); doSome
import the async module to have an asynchronous 'map' method
async
map
var async = require('async'); var arr = ['1','2']; async.map(arr, getInfo, function (e, r) { console.log(r); }); function getInfo(name, callback) { setTimeout(function() { callback(null, name + 'new'); }, 1000); }