> That's a big assumption
No, it's not. At all. It's part of the DOM Level 2 standard that specifies what `addEventListener` does and has been for going on 20 years.
https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-...
Well I don't see it used in a lot of code, so in that respect I think it is obscure. Also, using the "self" approach allows one to lexically bind to the enclosing scope, which aligns nicely with how most functional programmers think.
> Well I don't see it used in a lot of code, so in that respect I think it is obscure.
You just moved the goalposts.
Agreed. Much prefer 'var self = this' style. Keep the model transparent for future maintenance.
One time I don't is in Jasmine, where they explicitly state that 'this' is shared across all 'beforeEach', 'it' and 'afterEach' calls. Which backs up your first point.
This is where I've landed with the JavaScript that I write. It keeps things relatively sane, at least better than the other approaches I've tried.
I thought self had gone out of favor due to its relatively new global purpose.
The code using "self" doesn't have this problem; it's more self-contained so to speak (no pun intended).