All:
I wonder if I want to bind this to an object function, how can I do that? Like:
var a = {
name:"nihao",
hello: (function(){
console.log(this.name);
}).bind(this)
}
When I run a.hello(), the this is Window. Then I change the code to :
var a = {
name:"nihao",
hello: (function(){
console.log(this.name);
}).bind(a)
}
Nothing changes, so I wonder how can I bind a as this when I init this object?
Thanks