Map 用法:
// var obj={}; // obj.name="zhangsan"; // obj.age=24; // obj.say=function () {alert("hello world!"); } // //// alert(obj.name); //// alert(obj.age); //// obj.say(); //// for(var a in obj) //// { //// alert(obj[a]); //// //// } // // obj.p // alert(obj.hasOwnProperty('name')); function Map() { var obj={}; this.put=function(Key,value) // 加入绑定数组到对象 { obj[Key]=value; } this.size=function () // 查看数量 { var count =1; for(var att in obj){ count++ ;} return count; } this.get=function(key) // 获取 { if(obj[key] || obj[key]===0 || obj[key]===false){return obj[key]; } else {return null ;} } this.remove=function(key) //删除 { if(obj[key] || obj[key]===0 || obj[key]===false){ delete obj[key]; } } this.eachMap=function (fn) //遍历所有值 { for(var att in obj) { fn(att,obj[att]); } } } var m=new Map(); m.put('01','a'); m.put('02',0); m.put('03',false); m.put('04',new Date()); // alert(m.size()); // alert(m.get('03')); // m.remove('03') // alert(m.get('03')); m.eachMap(function(key,value){ alert(key+":"+value) }); //遍历m中所以值