How to create an associative array in JavaScript literal notation

前端 未结 6 705
再見小時候
再見小時候 2021-01-30 16:39

I understand that there are no associative arrays in JavaScript, only objects.

However I can create an array with string keys using bracket

6条回答
  •  再見小時候
    2021-01-30 17:27

    You can do what you wanted to do this way:

    myNewArray = new Array ({'a' : 200, 'b' : 300})
    

提交回复
热议问题