I have:
var f1 = function(a){
alert(a)
}
var f2 = function(data, method){
method(data) // the problem is here,
// the method f1 is not called. Is there a way to call that method f1?
// the method f1 might not be in this scope, the method f1 can
// be in a class or like this...
}
f2(a, f1)
The question is: Is there a way to call that f1 from f2, from the passed method?
thanks
EDIT: this is some code I write here, but I miss to set the a. anyway the value of is 5.
EDIT: yes! it was just a tiny stupid error in my original code that missed up, i set the value after calling the method. hehe
Try running your Javascript through a debugger. You’ll get a message like
a is not definedbecause the callf2(a, f1)is trying to pass a variable namedabut you haven’t declared one. However, this code will work: