The situation is somewhat like-
var someVar = some_other_function();
someObj.addEventListener(\"click\", function(){
some_function(someVar);
}, false);
<
Function.prototype.bind() is the way to bind a target function to a particular scope and optionally define the this
object within the target function.
someObj.addEventListener("click", some_function.bind(this), false);
Or to capture some of the lexical scope, for example in a loop:
someObj.addEventListener("click", some_function.bind(this, arg1, arg2), false);
Finally, if the this
parameter is not needed within the target function:
someObj.addEventListener("click", some_function.bind(null, arg1, arg2), false);