ã³ã¼ã«ããã¯é¢æ°ã«thisã渡ã
ä»ãªããã¢ãã¼é¢æ°ã使ãã°ãããªããåæã«æ¸¡ãã¾ãã
var that = thisã¨ãä¸æ¦å¤æ°ã«ä»£å ¥ããã
.bind(this)ã¨ããã¦ããã®ãæãããã§ããã
- that(self)ã¨ãå¥ã®å¤æ°ã«thisãå ¥ãã奴
var self = this; something( function () { // callback stuff } )
- å¿åé¢æ°ã®å¼æ°ã«å ¥ãã奴
( function( self ) { something( function () { // callback stuff } ); } )( this );
- ããã¦bind
var self = this; something( function () { // callback stuff }.bind(this) )
- ããã¦ã¢ãã¼é¢æ°
something( () => { // callback stuff } )
ä½ãããªãã¦ãå¤å´ã®thisã渡ãã¾ãã