Does JQuery support Dictionaries (key, value) collection?

后端 未结 5 998
余生分开走
余生分开走 2020-12-24 02:11

Does JQuery support Dictionaries (key, value) collection ?

I would like to set the following data in a structure

[1, false]
[2, true]
[         


        
5条回答
  •  生来不讨喜
    2020-12-24 02:25

    jQuery, no. But JavaScript does. There are only two structures in JavaScript, arrays and objects.

    Objects can be used as dictionary, where the properties are the "keys":

    var dict = {
        1: true,
        2: true,
        3: false
    };
    

    Properties of objects can be either accessed with dot notation, obj.property (if the property name is a valid identifier, which a digit as used above is not) or with array access notation, obj['property'].

提交回复
热议问题