Javascript, adding string to array[string]
<p>I have two variables:</p>

<pre><code>var cost = new Array();
var maxslot = new Array();
</code></pre>

<p>and I set the values like this:</p>

<pre><code>&lt;script&gt;
cost = {"m2mp":"0.05"};
maxslot = {"m2mp":"1000"};
&lt;/script&gt;
&lt;script&gt;
cost = {"samp":"0.04"};
maxslot = {"samp":"500"};
&lt;/script&gt;
</code></pre>

<p>But <code>samp</code> replaces <code>m2mp</code> and if I call <code>alert(cost["m2mp"])</code>, it outputs <code>undefined</code> (if I don't assign <code>samp</code>, I get the correct output). I tried replacing <code>=</code> with <code>+=</code>, but it did not help (<code>samp</code> and <code>m2mp</code> are both <code>undefined</code> then).</p>

<p>I couldn't find any solution to "simulate" this:</p>

<pre><code>cost["string"] = string;
</code></pre>
