|
|
|
|
|
by ender7
4916 days ago
|
|
Sadly, one last, unfortunate inconsistency: All event handlers have the value of 'this' bound to the object that emitted the event: var div = document.createElement('div');
div.addEventListener('click', function(e) {
console.log(this); // prints <div></div>
});
|
|
The underlying statement is that "event handler" is not a concept in JS, it's just a way of calling functions that some implementations use for some things (browsers for actions, node for I/O, etc...).
In fact, this didn't use to be true of old IE versions if I remember correctly, so it's not a matter of the language, but of what the browser does with your function during event firings.