这是一个风格问题,也许是主观的。
哪个更适合用于可读的标准代码?
A:" var context = this"
var object = {
foo: 'bar',
method: function(){
$.get('/some/async/api', (function (req, res){
console.log(this.foo); //==> bar
}).bind(this));
}
}
B:" .bind(this)"
WebView webView = new WebView(this);
webView.loadUrl("http://www.google.com/");
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setView(webView);
dialog.setPositiveButton("Okay", null);
dialog.show();