javascript 实现键值对。

来源:互联网 发布:日历记事本软件下载 编辑:程序博客网 时间:2024/05/01 22:16
<script type="text/javascript">function Dictionary(){  this.data = new Array();  this.put = function(key,value){   this.data[key] = value;  }; this.get = function(key){   return this.data[key];  }; this.remove = function(key){   this.data[key] = null;  };  this.isEmpty = function(){   return this.data.length == 0;  }; this.size = function(){   return this.data.length;  }; }function test(){var d = new Dictionary();d.put("china","中国");var a = d.get("china");document.write(a);}test();</script>