Javascript passing and using that function -
i have:
var f1 = function(a){ alert(a) } var f2 = function(data, method){ method(data) // problem here, // method f1 not called. there way call method f1? // method f1 might not in scope, method f1 can // in class or this... } f2(a, f1)
the question is: there way call f1 f2, passed method? thanks
edit: code write here, miss set a. anyway value of 5. edit: yes! tiny stupid error in original code missed up, set value after calling method. hehe
try running javascript through debugger. you'll message a not defined
because call f2(a, f1)
trying pass variable named a
haven't declared one. however, code work:
var f1 = function(a){ alert(a); } var f2 = function(data, method){ method(data); } var = 'this a'; f2(a, f1); // results in alert('this a')
Comments
Post a Comment