// 自定义字典对象
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;
};
}
使用
var d = new Dictionary();
d.put(key,value);
这样就可以拿来直接用了
本文介绍了一种在JavaScript中自定义实现字典对象的方法,包括put、get、remove等基本操作,并提供了简单的使用示例。

2616

被折叠的 条评论
为什么被折叠?



