jquery知识点温习

  • grep方法对数组元素进行筛选  

   1 $.grep(arr,function(value,index){return 为真则保留该元素},bol) 

   第三个参数,默认为false,为true则表示逆向运算,原先符合条件的返回,现在是不符合条件的返回。

  •  根据对象中的某个属性对数组进行排序
1 var obj = [
2         {name:'zhansan',age:12},
3         {name:'lisi',age:9},
4         {name:'wangwu',age:18}
5     ]
6     var newObj = obj.sort(function(a,b){ 7 return a.age - b.age; 8 })
  •    

猜你喜欢

转载自www.cnblogs.com/sujianfeng/p/9784678.html