I have an object which contains an array, and I want it to contain an associative array so keys are strings. How can I do it?
This does not work:
{profiles: { easy:["example" : 1], advanced:["example" : 1] }
I wanted to avoid
console.log({profiles: { easy: {"example": 1}, advanced:{"example": 1} })
Because that easy and advanced members are not displayed as an array but as an object.
Another way I know is this:
array['key2'] = 'new value';
but that is not part of the object, so I would need to split the command for multiple lines - which is not what I want.
PHP has something like array("mykey" => "myValue"), but does JavaScript have something similar?
Yet I don't want to use frameworks. This is JavaScript only.