比方說,我有變量是這樣的:JQuery的結合變量名
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;
*「我不知道如何結合字符串連接的x和localStorage.var * a」*。然後您可以使用括號表示法來訪問該屬性。請參閱https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Member_Operators。 –