var currentURL;
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
currentURL = tabs[0].url;
chrome.tabs.remove(tabs[0].id);
console.log(currentURL);
});
console.log(currentURL);
The above code is supposed to assign the URL of current page to variable "currentURL", however, the console log inside the function logs the correct value, while the one outside the function logs "undefined".
I cannot figure out why "currentURL" 's value is undefined outside the function, any help would be greatly appreciated!