Can I add a variable to the callback area? I want to achieve:
...
Foo.prototype.bar = function (fn) {
var baz = "baz!";
fn.call (this);
}
...
Foo.bar (function () {
console.log (baz) // gives "baz!"
});
I know that I can pass the baz variable as an argument or this , but I'm interested in something like the above.
source share