All the documentation I’ve found so far is to update keys that are already created:
arr['key'] = val;
I have a string like this: " name = oscar "
And I want to end up with something like this:
{ name: 'whatever' }
That is, split the string and get the first element, and then put that in a dictionary.
Code
var text=" name = oscar "
var dict = new Array();
var keyValuePair = text.split(' = ');
dict[ keyValuePair[0] ] = 'whatever';
alert( dict ); // Prints nothing.