I have a code like this
function SocialMiner()
{
var verbose=true;
var profileArray=new Array();
var tabUrl;
this.getTabUrl=function(callback)
{
chrome.tabs.getSelected(null, function(tab)
{
myUrl = tab.url;
console.log("0"+tab.url);
console.log("calling callback");
callback.call(tab.url);
});
}
this.setTabUrlValue=function(pageUrl)
{
console.log("1"+pageUrl);
tabUrl=pageUrl;
}
};
I call the first method with second as callback
var pageUrl=miner.getTabUrl(miner.setTabUrlValue);
What I observe is that , second function does not receives the value, i.e. pageUrl is undefined, however it was correctly passed in first function. Any pointers ?
Your syntax to
callis incorrect; the first parameter tocallis what determines the value ofthisinside of the function you’re calling. The second argument is where you would place an array of arguments to pass to the functionYou could simply use
in this case.
If you wanted to use
call: