Is it possible to create a javascript array similar to PHP's method which allows you to define the keys during creation?
$arr = array("foo" => "bar", 12 => true);
Or can this only be done like:
myArray["foo"] = "bar";
myArray[12] = true;
Is it possible to create a javascript array similar to PHP's method which allows you to define the keys during creation?
$arr = array("foo" => "bar", 12 => true);
Or can this only be done like:
myArray["foo"] = "bar";
myArray[12] = true;
In javascript you can achieve this with objects:
var arr = {
foo: 'bar',
12: true
};