zoukankan      html  css  js  c++  java
  • Js Linq

    Linq是对前端集合变量进行操作的一种技术框架,引用文件linq.min.js。
    var myList = [
                { Name: "Victor", Age: 28 },
                { Name: "Jack", Age: 30 },
                { Name: "Simon", Age: 26 },
                { Name: "Hellen", Age: 27 },
                { Name: "Felix", Age: 28 }
        ];
    1.where条件筛选
    var results=myList .where(function(t){return t.Name=="Victor"});
    //返回[{ Name: "Victor", Age: 28 }]
    
    2.select获取指定的属性
    var results=myList .select(function(t){return t.Age});
    //返回[28, 30, 26, 27, 28]
    
    3.orderBy排序
    var results=myList.orderBy(function(t){return t.Age});
    //返回[{ Name: "Simon", Age: 26 }, { Name: "Hellen", Age: 27 },{ Name: "Victor", Age: 28 }, { Name: "Felix", Age: 28 }, { Name: "Jack", Age: 30 }]
    
    4.distinct去重
    var results=myList.distinct(function(a,b){return a.Age==b.Age});
    //[{ Name: "Simon", Age: 26 }, { Name: "Hellen", Age: 27 },{ Name: "Victor", Age: 28 }, { Name: "Jack", Age: 30 }]
    
    5.forEach遍历
    myList.forEach(function(value,index){console.log("Name:"+value.Name+"Age:"+value.Age);})
  • 相关阅读:
    MySQL数据库分页
    Spring MVC
    Spring框架
    Java学习计划(转载)
    开发用户注册模块
    Ajax技术
    Jodd Email 发送邮件
    DOM技术
    MD5加密
    final关键字的使用
  • 原文地址:https://www.cnblogs.com/learning-life/p/10718245.html
Copyright © 2011-2022 走看看