3
如何更新數組(鍵,值)對象?我更新了javascript中的數組(鍵,值)對象
arrTotals[
{DistroTotal: "0.00"},
{coupons: 12},
{invoiceAmount: "14.96"}
]
我想將'DistroTotal'更新爲一個值。
我已經試過
for (var key in arrTotals) {
if (arrTotals[key] == 'DistroTotal') {
arrTotals.splice(key, 2.00);
}
}
謝謝..
js對象數組... – Dom 2013-02-12 00:21:09
JavaScript中的數組具有數字索引(鍵)。只要你推入非數字「索引」,它不再是一個數組。 – NullUserException 2013-02-12 00:21:28
@NullUserException我的錯誤,我認爲它是在說'var arrTotals = [ {DistroTotal:「0.00」}, {coupons:12}, {invoiceAmount:「14.96」} ] – Dom 2013-02-12 00:29:36