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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -