我有两个变量:
var cost = new Array();
var maxslot = new Array();
我设置这样的值:
<script>
cost = {"m2mp":"0.05"};
maxslot = {"m2mp":"1000"};
</script>
<script>
cost = {"samp":"0.04"};
maxslot = {"samp":"500"};
</script>
但是samp替换m2mp,如果我打电话alert(cost["m2mp"]),它会输出undefined(如果我不分配samp,我会得到正确的输出)。我尝试用 替换=,+=但它没有帮助(samp并且m2mp两者都是undefined)。
我找不到任何解决方案来“模拟”这个:
cost["string"] = string;