JS 自己实现Map
2024-10-17 00:43:04
function MyMap() {
var items = {}; this.has = function (key) {
return key in items;
};
this.set = function (key, value) {
items[key] = value;
};
this.remove = function (key) {
if (this.has(key)) {
delete items[key];
return true;
}
return false;
};
this.get = function (key) {
return this.has(key) ? items[key] : undefined;
};
this.values = function () {
var values = new Array();
for (var k in items) {
if (this.has(k)) {
values.push(items[k]);
}
}
return values;
};
this.getItems = function () {
return items;
};
this.clear = function () {
items = {};
};
this.getCount = function () {
return Object.keys(items).length;
}; }
最新文章
- 显示快照监控:/SDF/MON
- 服务器重启后SQL Server Agent由于";The EventLog service has not been started"; 启动失败
- Centos 7 ASP.NET Core 1.0 Docker部署
- maven继承parent,relativePath warn信息的解决办法
- 推荐一个linux下的web压力测试工具神器webbench
- 从Wordpress迁移到Jekyll
- [React] Using the classnames library for conditional CSS
- android中设置TextView/Button 走马灯效果
- MLAPP——概率机器学习知识汇总
- Unity Object Pool完全体
- phpstudy中的mysql
- c# 语法要点速览
- P1546 最短网络 Agri-Net题解(克鲁斯卡尔)
- centos查看自启动服务
- [转帖]国产闪存颗粒终于熬出头 紫光存储S100固态硬盘评测
- Android: Custom View和include标签的区别
- css中实现ul两端的li对齐外面边缘
- wifiphisher使用介绍
- windows服务的安装和卸载方法
- c#简单加密和对称加密