are there dictionaries in javascript like python?

前端 未结 7 714
轻奢々
轻奢々 2020-12-07 18:59

i need to make a dictionary in javascript like this

i dont remember the exact notation, but it was something like:

states_dictionary={ CT=[alex,harry         


        
相关标签:
7条回答
  • 2020-12-07 19:36

    Firefox 13+ provides an experimental implementation of the map object similar to the dict object in python. Specifications here.

    It's only avaible in firefox, but it looks better than using attributes of a new Object(). Citation from the documentation :

    • An Object has a prototype, so there are default keys in the map. However, this can be bypassed using map = Object.create(null).
    • The keys of an Object are Strings, where they can be any value for a Map.
    • You can get the size of a Map easily while you have to manually keep track of size for an Object.
    0 讨论(0)
提交回复
热议问题