Is there a short way of declaring an associative array like in PHP?
$myArray = array(\'a\' => \'b\'); // PHP Way
In JavaScript I\'d do i
JavaScript does not have associative arrays. In your example, you declare myArray as array but then you assign an object to it. So your code is not different from this:
var myObject = {};
myObject['a'] = 'b';
Update: A little correction. Actually, the original code does not destroy the array. It just appends a regular property to it. That's possible because JavaScript arrays are a subset of JavaScript objects.