I am building a chrome extension and got stuck here. It's a simple javascript problem but since I am no expert in javascript, any help would be appreciated.
function active()
{
chrome.extension.sendRequest({cmd:"mycommand"}, function(callback)
{
if(callback.mydata)
{
return true;
}
else
{
return false;
}
});
}
console.log(active()); //prints undefined
I know that if it had been a simple nested function case, I'd need to call the inner one first, like
function active()
{
function inner()
{
//some task
return true;
}
return inner();
}
console.log(active()); //works
But I've never come across a case as I'm facing now.