DEV Community

Discussion on: Writing Good Method & Variable Names

Collapse
 
darrylhodgins profile image
Darryl Hodgins

There's the industry-standard Javascript hack…

var that = this;

Collapse
 
rachelsoderberg profile image
Rachel Soderberg

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.

Collapse
 
anwar_nairi profile image
Anwar • Edited

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!

Collapse
 
rachelsoderberg profile image
Rachel Soderberg

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!