js使用try-catch模拟块状作用域
var result=[];
function foo(){
var i= 0;
for (;i<3;i=i+1){
try{
throw i;
}catch(i){
result[i]= function(){
alert(i);
};
}
}
};
foo();
result[0](); // 0
result[1](); // 1
result[2](); // 2