I’m not sure exactly how to phrase my question, so let me present an example:
function foo() {
window.addEventListener("keydown", function(event) {
bar(event.keycode);
}
foo.prototype.bar = function (keycode) {
//code
}
I’ve tried using this.bar(), but that results in using the window as this. Is there a way to do this, or will I have to call another initialize method manually?
Bind
this.bartothisbefore you pass it.demo http://jsfiddle.net/2tee4/