Skip to content

Instantly share code, notes, and snippets.

@junfenglx
Created October 23, 2013 08:54
Show Gist options
  • Save junfenglx/7115016 to your computer and use it in GitHub Desktop.
Save junfenglx/7115016 to your computer and use it in GitHub Desktop.
var name="Window";
var Top={
name:"top",
Inner:{
name:"inner",
getName:function(){
var that=this;
var i=0;
function increase(){
var rt="this binding:"+this.name+"\n\n"+"number i:"+i;
i++;
return rt;
};
i++;
return increase;
}
}
};
var closure1=Top.Inner.getName();
alert("first call closure1"+"\n"+closure1());
var closure2=Top.Inner.getName();
var closure21=closure2;
alert("first call closure2"+"\n"+closure2());
alert("againe call closure1"+"\n"+closure1());
alert("againe call closure2"+"\n"+closure2());
alert("first call closure21"+"\n"+closure3());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment