I have an associative array in JS.
var array = {
'one' : 'first',
'two' : 'second',
'three' : 'third'
};
How can I add new pair in it
I have an associative array in JS.
var array = {
'one' : 'first',
'two' : 'second',
'three' : 'third'
};
How can I add new pair in it
array['newpair'] = 'new value';
or
array.newpair = 'newvalue';
This is quite a decent read on the subject.
It's an object literal, not really an "associative array".
Just do array['something'] = 'something';