I'm having a problem with an array becoming undefined and I can't figure out why.
I declare the variable ul, I then get the array from storage and assign it to ul, if I try to work with it inside the get function it works, I can do whatever I want, if I try to do anything with outside of the get function it just says it's undefined.
function getUserList()
{
var ul;
chrome.storage.local.get({'users':[]}, function(result){ //get user array from storage
ul = result.users; //get users from result
console.log(ul); <-this works
});
console.log(ul); <- this does not
hideSubmissions(ul); <- or this
hideComments(ul); <- or this
};
getUserList();
I can move everything that uses ul into the get function but I'd like to know why that is necessary, the only thing I can guess at is that it is somehow going out of scope but I don't see how.