【发布时间】:2016-05-06 18:26:49
【问题描述】:
如何在for循环内部动态生成变量并赋值?
例如,
var tempClosingBalance, k = 1;
for (var i = 0; i < customArray.length; i++) {
tempClosingBalance = "ClosingBalanceWithType" + k;
for (var j = 0; j < output.length; j++) {
output[j].tempClosingBalance = customArray[i][j].ClosingBalanceWithType;
}
k++;
}
这里tempClosingBalance变量有ClosingBalanceWithType1并赋值,同样的条件在ClosingBalanceWithType2、ClosingBalanceWithType3等处继续赋值
【问题讨论】:
-
这与jQuery无关
标签: jquery