Reputation: 13
Here is my code i want alert to give (some data) value. which is of inner function it give undefined value
alert(f1());
function f1(){
f2(function (){
return "some data";
});
}
function f2(f4){
// some code
}
visit : https://jsfiddle.net/dvdhyttr/8/
i want alert get value (some data). but getting undefined.
Upvotes: 0
Views: 212
Reputation: 33726
f1
f2
you need to return the result of calling the function f4
.alert(f1());
function f1() {
return f2(function() {
return "some data";
});
}
function f2(f4) {
return f4()
}
Upvotes: 1
Reputation: 370739
You need to assign the return values of the functions to variables in the outer function and return them, all the way up to alert(f1());
.
alert(f1());
function f1() {
const resultOfF2 = f2(function() {
return "some data";
});
return resultOfF2;
}
function f2(f4) {
return f4();
// some code
}
Upvotes: 0