JS associative arrays: add new pair
22,731
Solution 1
array['newpair'] = 'new value';
or
array.newpair = 'newvalue';
This is quite a decent read on the subject.
Solution 2
It's an object literal, not really an "associative array".
Just do array['something'] = 'something';
Author by
Artur Keyan
Updated on April 29, 2021Comments
-
Artur Keyan about 3 years
I have an associative array in JS.
var array = { 'one' : 'first', 'two' : 'second', 'three' : 'third' };
How can I add new pair in it