Could someone explain to me what's wrong with checkX()'s scope? What I'm suspecting that's wrong is the anonymous function somehow blocks it but I'm not sure how to bypass that.
storage = chrome.storage;
function checkX(){
var x = false;
storage.sync.get(function(data){
if(data.x == true){
x = true;
console.log(x); // << x : true
}
});
console.log(x); // << x : false
return x;
}
console.log result order:
x : false
x : true