假设我有这样的变量:
localStorage.var1a = 0;
localStorage.varnum = 1000;
这样的代码:
for(x = 1; x <localStorage.varnum;x++){
if(localStorage.var.x.a > 0){
localStorage.var.x.a = Number(localStorage.var.x.a)
}else{
localStorage.var.x.a = 0;
}
}
我的问题是,我不知道如何组合x和localStorage.var * a;
答案 0 :(得分:0)
if(localStorage["var"+x+"a"] > 0){
localStorage["var"+x+"a"] = Number(localStorage["var"+x+"a"]);
}else{
localStorage["var"+x+"a"]= 0;
}