4 ms·
If you're talking about variables in closures, a coworker of mine has a pretty clever way to do it: "var _this = this". It's just a generally useful part of jav
by ayu 15y ago
If you're talking about variables in closures, a coworker of mine has a pretty clever way to do it: "var _this = this". It's just a generally useful part of javascript.
- mark_story 15y agoI find _this and that are the most common ways of referring to the enclosed this. I would avoid using self like the plague because of window.self though.
- armandososa 15y agoThis is one of the reasons I love CoffeeScript and the fat arrow.
- ludwigvan 15y agoI usually do var $that = $(this);, the $ prefix is a Hungarian notation trick that shows variables that have been jQuery'fied.