var globalVar = "";
async.series([
function(next){
db.collection.find({query}}).toArray(function(err, result) {
/*there is a function which updates the
value of globalVar to "someupdatedText"*/
console.log(globalVar); //someupdatedText
next(err);
})
},
function(next){
console.log(globalVar); //undefined
next();
}
]);
What could be the problem? In first function I can access the global variable and update its value but in the second function globalVar returns undefined. Is it about node.js? What do I miss?