deferredの中の関数のthis
function Klass () { } Klass.prototype.run = function () { try { doSimpleXMLHttpRequest( "/" ).addCallback( bind(function (res ) { console.log(res, self, this) }, this) ); }catch(e){ console.log(e) } } var k =new Klass(); k.run()
bindしなかったらwindowを指してた。考えてみたらあたりまえ。
コンストラクタの中で bindMethods(this) を呼ぶとあと何も考えなくていいから楽。