How to create Hash object/array using jquery?

前端 未结 5 1104
挽巷
挽巷 2021-01-05 18:55

I know there is a Hash() object in the Javascript prototype framework, but is there anything in Jquery like this?

As I would like to stick with one javascript framew

5条回答
  •  天命终不由人
    2021-01-05 19:46

    I think you don't need jQuery for this.

    var hashtable = {
        hash: {},
        exists: function(key){
           return this.hash.hasOwnProperty(key);
        },
        get: function(key){
            return this.exists(key)?this.hash[key]:null;
        },
        put: function(key, value){
            this.hash[key] = value;
        }
    }
    

提交回复
热议问题