P
Philippe Poulard
Hi folks !
I have some code like this that passes an anonymous function:
foo.bar(p1, function(p2) {
alert(p2);
});
in foo.bar, i create a button with a listener; when it is executed, the
following code fails to run:
bar : function(somePara, someFunction) {
...
someButton.addListener("execute", function(e) {
someFunction(someData);
});
...
}
I google for some documentation and this version works well:
bar : function(somePara, someFunction) {
...
someButton.addListener("execute", function(e) {
someFunction.call(null, someData);
});
...
}
I don't understand the difference between f.apply(), f.call() and f()
and why the latter doesn't work
In fact, when using f("foo") the function is executed (I'm sure of that
when I insert alert("Hello")), but without its argument if in the body
of the anonymous function i use alert(p2) it fails
Please can you explain this behaviour ?
--
Cordialement,
///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
I have some code like this that passes an anonymous function:
foo.bar(p1, function(p2) {
alert(p2);
});
in foo.bar, i create a button with a listener; when it is executed, the
following code fails to run:
bar : function(somePara, someFunction) {
...
someButton.addListener("execute", function(e) {
someFunction(someData);
});
...
}
I google for some documentation and this version works well:
bar : function(somePara, someFunction) {
...
someButton.addListener("execute", function(e) {
someFunction.call(null, someData);
});
...
}
I don't understand the difference between f.apply(), f.call() and f()
and why the latter doesn't work
In fact, when using f("foo") the function is executed (I'm sure of that
when I insert alert("Hello")), but without its argument if in the body
of the anonymous function i use alert(p2) it fails
Please can you explain this behaviour ?
--
Cordialement,
///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |