Created
October 23, 2013 08:54
-
-
Save junfenglx/7115016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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