• 数组中对象的去重


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>es6-set</title>
    </head>
    <body>
        
    <script type="text/javascript">
    var arr = [{
        "name": "ZYTX",
        "age": "Y13xG_4wQnOWK1QwJLgg11d0pS4hewePU95UHtpMl3eE81uS74NC-6zu-Rtnw4Ix",
        "gender": "AAAAAA.doc"
    }, {
        "name": "ZYTA",
        "age": "Y13xG_4wQnOWK1QwJLgg11d0pS4hewePU95UHtpMl3eE81uS74NC-6zu-Rtnw4Ix",
        "gender": "BBBBBB.doc"
    }, {
        "name": "ZDTX",
        "age": "Y13xG_4wQnOWK1QwJLgg11d0pS4hewePU95UHtpMl3eE81uS74NC-6zu-Rtnw4Ix",
        "gender": "CCCCCC.doc"
    }, {
        "name": "ZYTX",
        "age": "Y13xG_4wQnOWK1QwJLgg11d0pS4hewePU95UHtpMl3eE81uS74NC-6zu-Rtnw4Ix",
        "gender": "AAAAAA.doc"
    }];
    var hash = {};
    arr = arr.reduce(function(item, next) {
        console.log(item);
        console.log(next);
        console.log(hash[next.name] );
        hash[next.name] ? '' : hash[next.name] = true && item.push(next);
        console.log(hash);
        console.log(item);
        console.log("==================");
        return item
    }, [])
    console.log(arr);
    </script>
    </body>
    </html>
  • 相关阅读:
    nginx日志、变量
    http相关
    nginx.conf文件的使用
    NA交换①
    第一章 何为网络
    第二章 以太网
    SATA、SCSI、SAS
    第十章 安全
    附录A 思科互联网络操作系统(IOS)
    标准ACL、扩展ACL和命名ACL的配置详解
  • 原文地址:https://www.cnblogs.com/vscss/p/8232829.html
Copyright © 2020-2023  润新知