原文地址:适用js数组存放键值对map作者:枫悬

//自定义Map对象
function Map(){
 this.keys = new Array();
 this.data = new Array();

 
 this.put = function(key,value){
  if(this.data[key] == null){
   this.keys.push(value);
  }
  this.data[key] = value;
 };

 
 this.get = function(key){
  return this.data[key];
 };

 
 this.remove = function(key){
  this.keys.remove(key);
  this.data[key] = null;
 };

 
 this.isEmpty = function(){
  return this.keys.length == 0;
 };

 
 this.size = function(){
  return this.keys.length;
 };
}

 

 

 

//使用 例子

var  bb = new Map();

bb.put("cc",dd);

 

alert(bb.get("cc"));

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案