jquery - javascript variable scope -
i have below code,
it running output in console is
instant: true
instant2: false
as variable not being overwritten in global scope. how can access variable in global scope?
var instant = false; $('document').ready(function(){ chrome.extension.sendrequest({ action: "getstorage", key: "instant" }, function(response) { instant = true; console.log('instant: ', instant); }); console.log('instant2: ', instant); });
it getting overridden, later. function(response)
isn't getting executed until after outer function returns.
Comments
Post a Comment