Array.prototype.map_init = function(){
this.keys = [];
}
Array.prototype.map_set = function(key , value){
if(this[key] == undefined){
this.keys.push(key);
}
this[key] = value;
}
Array.prototype.map_get = function(key){
var index = this.keys.indexOf(key);
if(index == -1){
console.log("key : "+key + "is not exist");
return null;
}
var key = this.keys[index];
return this[key];
}
Array.prototype.map_del = function(key){
var index = this.keys.indexOf(key);
if(index != -1){
this.keys.splice(index , 1);
}
if(this[key]){
delete this[key];
}
}
Array.prototype.map_keys = function(){
return this.keys;
}
(function load(){
var a = [];
a.map_init();
a.map_set("coim","id=1");
a.map_set("part","dd");
console.log(a.map_keys().length);
console.log(a.map_get("coim"));
console.log(a.map_get("part"));
})();
이렇게하면안되는거야? 함수가 정의 안됬다는데 난 무슨말인지 이해가안감 ㅇㅇ;
댓글 0