How can I get the value of var result in this code?
I know this is a basic problem but I'm looking for the solution since 3 days. Can you give me any suggestion please?
function foo(myCallback){
}
function bar() {
var result = foo(function(){
var result = "hello";
return result;
});
}
var showResult = bar();
alert(showResult);
callbackfunction foo(myCallback) { } function bar(cb) { foo(function() { var result = "hello"; cb(result); }); } bar(function(res) { alert(res); });