jQuery的map使用

jQuery的map使用

var a = {id:'12345', name:"张三"};
var b = {id:'lisi', name:"李四"};
var map = {};
map.zhangsan = '张三';
alert(map.zhangsan);

map[12345] = '张三1';
map['lisi'] = '李四';
alert(map[12345]);
alert(map['lisi']);
  
var map=[{id:'1',name:'dong'},{id:'2',name:'zhang'}];
$.test=function(id){
      for(var i=0;i<map.length;i++){
              if(id==map[i].id){
                     alert(map[i].name);
              }
       }
}

相关推荐