javascript の this, that, self, _this ...
var _this = this; setTimeout(function(){ _this.hoge(); }, 1000);
this を保持するための変数名は、色々あるけど、
僕は、断然 _this を推したい。
消去法で。
- that → 変数名として意味が通じない。
- self → var つけ忘れたら window.self 書き換えちゃうし、未定義でアクセスしてもエラー出ないんだけど。
- _this → 何を指してるのか明確。検索にかかる。
Coffeescript とかもコンパイルすると _this です。