In C++, you have a bind function that allows you to bind parameters to functions. When you call the function, it will be called with those parameters. Similarly, MySQL has an ability to bind parameters to queries where it will substitute question marks with the variable. In Javascript and jQuery, the bind function has a confusingly different meaning. It makes the passed parameter the this variable, which is not at all what I want. Here's an example of what I want to achieve:
var outerVariable;
var callbacks = [
some_object.event,
some_object.differentEvent.bind(outerVariable)
];
// func() will automatically have outerVariable in scope
$.map(callbacks, function(func) { func(); });
outerVariablewill be in scope regardless, since it is higher up the scope chain thanfunc