JS associative arrays: add new pair

前端 未结 2 2023
无人共我
无人共我 2021-02-19 15:51

I have an associative array in JS.

var array = {
    \'one\' : \'first\',
    \'two\' : \'second\',
    \'three\' : \'third\'
};

How can I add

2条回答
  •  醉梦人生
    2021-02-19 16:29

    It's an object literal, not really an "associative array".

    Just do array['something'] = 'something';

提交回复
热议问题