<script type="text/javascript">
(function () {
function map() {
var arr = {};
//增加
this.put = function (key,value) {
arr[key] = value;
}
//查询
this.get = function (key) {
if (arr[key]) {
return arr[key];
}else{
return null;
}
}
//修改
this.set = function (key,value) {
arr[key] = value;
}
//删除
this.remove = function (key) {
delete arr[key];
}
//遍历
this.each = function (fn) {
for (var key in arr[key]) {
fn(key,arr[key]);
}
}
}
})();
</script>
js map类的实现
最新推荐文章于 2023-04-26 11:30:25 发布