javascript closure anonymous function
<script>
var a="s";
function aaa()
{
var arr=[];
for(var i=0;i<3;i++)
{
(function(){
var obj= new Object();
var ss=i;
obj.show=function()
{
alert(ss);
}
arr[arr.length]=obj;
})();
}
for(var j=0;j<arr.length;j++)
{
arr[j].show();
}
}
aaa();
</script>
var a="s";
function aaa()
{
var arr=[];
for(var i=0;i<3;i++)
{
(function(){
var obj= new Object();
var ss=i;
obj.show=function()
{
alert(ss);
}
arr[arr.length]=obj;
})();
}
for(var j=0;j<arr.length;j++)
{
arr[j].show();
}
}
aaa();
</script>