javascript实现HashMap

function HashMap(){
    var hashMap = {   
            Set : function(key,value){this[key] = value},   
            Get : function(key){return this[key]},   
            Contains : function(key){return this.Get(key) == null?false:true},   
            Remove : function(key){delete this[key]}   
        } 
    
    return hashMap;
}

调用

var hashMap_bengzhan = new HashMap();
hashMap_bengzhan.Set("NM","名称");
hashMap_bengzhan.Set("TM","时间");

  

posted @ 2017-03-09 17:06  marost  阅读(164)  评论(0编辑  收藏  举报