function test(){
this.a = 1;
return a;
}
var a = test(); //a equals 1, this context in test will be window
var b = new test(); //b equals "test {a: 1}", this context is the function's context
this.a = 1;
return a;
}
var a = test(); //a equals 1, this context in test will be window
var b = new test(); //b equals "test {a: 1}", this context is the function's context
No comments:
Post a Comment