我有以下 JavaScript 对象,其属性名为 rates,其中包含另一个具有实际费率的对象。现在我想在费率中添加一个新费率“CAD”:0.972254。我怎样才能将这个值添加到列表中?
var Currency = {
rates: {"USD":1.0,"EUR":1.3497,"GBP":1.60403},
convert: function(amount, from, to) {
return (amount * this.rates[from]) / this.rates[to];
}
};
最佳答案
关于javascript - 向嵌套的 javascript 对象添加另一个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19006500/