I sometimes encounter var self = this; too, kind of annoying. I prefer to use myFunction() { /* much stuff, very algorithm */}.bind(this) if I am in an event handler for example, much natural to work with this even if the bind is a bit ugly!
Thankfully I don't need to deal with this very often at this point, but I agree with you. I'll keep this style in mind and try to remember to use it whenever I encounter it again!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There's the industry-standard Javascript hack…
var that = this;
I think, at my current level, I'd probably just sit there and cry (or laugh maniacally) for a few minutes if I came across this.
I sometimes encounter
var self = this;
too, kind of annoying. I prefer to usemyFunction() { /* much stuff, very algorithm */}.bind(this)
if I am in an event handler for example, much natural to work withthis
even if the bind is a bit ugly!haha "much stuff, very algorithm" :)
Thankfully I don't need to deal with this very often at this point, but I agree with you. I'll keep this style in mind and try to remember to use it whenever I encounter it again!