how to push associative item into array in javascript?
<p>Please correct this code:</p>

<pre><code>var arr = [];    
var name = "name";
var val = 2;
arr.push(val); //works , but not associative
arr[name]  = val; //does not work
console.log(arr);​
</code></pre>

<p><a href="http://jsfiddle.net/bz8pK/" rel="nofollow">jsfiddle</a></p>
