javascript - Cannot update and use global variable in asynchronous functions -
var globalvar = ""; async.series([ function(next){ db.collection.find({query}}).toarray(function(err, result) { /*there function updates value of globalvar "someupdatedtext"*/ console.log(globalvar); //someupdatedtext next(err); }) }, function(next){ console.log(globalvar); //undefined next(); } ]);
what problem? in first function can access global variable , update value in second function globalvar returns undefined. node.js? miss?
Comments
Post a Comment