自分でJSで書いたMap(Activex Scripting.Dictionaryの代わりに使う)


現在のプロジェクトでは、FFに一部のコードを表示する必要があるため、古いコードのnew ActiveXObject(「Scripting.Dictionary」)で実現されたMapは使用できません.
zozohの指点は自分で1つ書いて、現在すでにプロジェクトの中で使用して、今みんなに分かち合います.
どこか間違いがあったら批判してほしい.

function Map() 
{
	this.map = {}; //initialize with an empty array
	this.Count=0;
}
Map.prototype.size = function() 
{
	return this.Count;
}
Map.prototype.Item = function(key) 
{
	if (this.Exists(key)) {
		return this.map[key];
	}else{
		return null;
	}
}
Map.prototype.Add = function(key, value){
    if (!this.Exists(key)) {
        this.Count++;
    }
    this.map[key] = value;
}
Map.prototype.Items = function() 
{
	var array = [];
	for(var key in this.map){
		array.push(this.map[key]);
	}
	return array;
}
Map.prototype.Keys = function() 
{
	var array = [];
	for(var key in this.map){
		array.push(key);
	}
	return array;
}
Map.prototype.Exists = function(key) 
{
	if(typeof this.map[key]!="undefined"){
		return true;
	}else{
		return false;
	}
}
Map.prototype.Remove = function(key) 
{
	var newMap={};
	for(var i in this.map){
		if(i!=key){
			newMap[i]=this.map[i];
		}else{
			this.Count--;
		}
	}
	this.map = newMap;
}
Map.prototype.RemoveAll = function() 
{
	this.map = {};
	this.Count=0;
}