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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -