zoukankan      html  css  js  c++  java
  • lodash 集合处理方法 map和filter区别

    <!DOCTYPE html>
    <html lang="zh">
    
        <head>
            <meta charset="UTF-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0" />
            <meta http-equiv="X-UA-Compatible" content="ie=edge" />
            <title>lodash 集合处理方法 map和filter区别</title>
        </head>
    
        <body>
            <script src="https://cdn.bootcss.com/lodash.js/4.17.10/lodash.min.js"></script>
            <script type="text/javascript">
                var users = [{
                        'user': 'barney',
                        'age': 36,
                        'active': true
                    },
                    {
                        'user': 'fred',
                        'age': 40,
                        'active': false
                    }
                ];
                //输出 ["barney", "fred"]
                console.log(_.map(users, 'user'))
                // 输出[{    'user': 'barney','age': 36,'active': true},{'user': 'fred','age': 40,'active': false}]
                console.log(_.filter(users, 'user'))
            </script>
        </body>
    
    </html>
  • 相关阅读:
    反射
    IO流
    集合(下)
    集合(上)
    泛型
    异常
    常用类
    内部类
    将博客搬至CSDN
    DBMS_ERRLOG记录DML错误日志(二)
  • 原文地址:https://www.cnblogs.com/mengfangui/p/9303362.html
Copyright © 2011-2022 走看看