1.var name="the window";
var object={
name:"my object",
getNameFunc:function(){
return function(){
return this.name;
};
}
}
alert(object.getNameFunc()())
//无括号是返回function(){
return function(){
return this.name;
//一个括号返回function(){
return this.name;
//两个括号返回the window
2.var name="the window";
var object={
name:"my object",
getNameFunc:function(){
var that=this;
return function(){
return that.name;
};
}
}
alert(object.getNameFunc()())
3.var name="the window";
var object={
name:"my object",
getNameFunc:function(){
return this;
};
}
}
alert(object.getNameFunc())
//SyntaxError: Unexpected token ;报错
//字面量里面多了一个分号,去掉后返回object object