I was wondering if it is possible to replace the scope object of a function in javascript. I have an event handler that is quite complicated, and I want to pull it out of another function and store it somewhere else. I then would like to be able to retrieve the handler, replace its scope, and pass it along as the handler.
Sample code:
function A(event){
}
function B(){
// many variables initialized here that I want to be available from within A...
// the line where I would like to bind these variables to A
$form.on("submit", A);
}