封装http请求键值对的js函数

 1 //封装http请求键值对的函数
 2 function Map() {
 3     this.keys = new Array();
 4     this.data = {};
 5     //添加键值对
 6     this.put = function(key, value) {
 7         if (this.data[key] == null) { //如键不存在则给键域数组添加键名
 8             this.keys.push(key);
 9         }
10         this.data[key] = value; //给键索引对应的值域赋值
11     };
12     //获取键对应的值
13     this.get = function(key) {
14         return this.data[key];
15     };
16     //去除键值,(去除键数据中的键名及对应的值)
17     this.remove = function(key) {
18         this.keys.remove(key);
19         this.data[key] = null;
20     };
21     //判断键值元素是否为空
22     this.isEmpty = function() {
23         return this.keys.length == 0;
24     };
25     //获取键值元素大小
26     this.size = function() {
27         return this.keys.length;
28     };
29 }

 

转载于:https://www.cnblogs.com/qiushuiblog/p/7093237.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值