Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
JavaScript: This is a trap, avoid it (bfred.it)
2 points by bfred_it on Aug 21, 2014 | hide | past | favorite | 2 comments


Depends on your team's conventions. I started doing this on a team where "var self = this" was the convention (lots of Backbone code), so to the rest of my team, "var view = this;" et. al were actually less readable (because they broke the reader's expectations).


I wrote this short article about "this" in the hope to make code more readable and save you from debugging time.

Feel free to comment on it here or call BS. I'm here to learn. :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: