I have javascript object defined like this:
function SocialMiner()
{
var verbose=true;
var profileArray=new Array();
var tabUrl;
this.getTabUrl=function()
{
logToConsole("getTabUrl is called");
chrome.tabs.getSelected(null, function(tab)
{
tabUrl = tab.url;
logToConsole(tabUrl);
});
return tabUrl;
} `
Then I call this function on SocialMiner ojbect like this:
var pageUrl=miner.getTabUrl();
miner.logToConsole(pageUrl);
What is the reason that first call to logToConsole successfully prints the Url, while second one says undefined. Am I not returning the same value from the function ?
Update: This is how I have defined logToConsole:
function logToConsole(text)
{
if (verbose)
console.log(text);
}
this.logToConsole=logToConsole;
logToConsolemethod on your SocialMiner object. You've made agetTabUrlmethod, but nologToConsole.