zoukankan      html  css  js  c++  java
  • 数组中对象去重

    let coupons=[ { "id": 95, "appId": "mitang", "deleted": false, "creator": null, "created": 1520560522000, "modifier": null, "modified": 1520560522000, "pageSize": null, "offset": null, "type": 1, "typeId": 76, "userId": 108, "guideId": 32216, "storeId": null, "couponId": 3, "couponSn": "mt0000000001", "startTime": 1520560522000, "endTime": 1520560522000, "couponName": "发生的发生", "remark": "", "couponPackId": null, "writeOff": 0, "face": "10" }, { "id": 95, "appId": "mitang", "deleted": false, "creator": null, "created": 1520560522000, "modifier": null, "modified": 1520560522000, "pageSize": null, "offset": null, "type": 1, "typeId": 76, "userId": 108, "guideId": 32216, "storeId": null, "couponId": 3, "couponSn": "mt0000000001", "startTime": 1520560522000, "endTime": 1520560522000, "couponName": "发生的发生", "remark": "", "couponPackId": null, "writeOff": 0, "face": "10" } ]
    let unique = {};
    coupons.forEach(function (gpa) {
    unique[JSON.stringify(gpa)] = gpa
    });
    coupons = Object.keys(unique).map(function (u) {
    return JSON.parse(u)
    });

      数组中不支持直接比较对象;

  • 相关阅读:
    pytorch常用函数
    检测(2):开始训练
    gcc的替换,很有用
    detection-pytorch环境配置的遇到的坑
    一些有用的ubuntu命令总结---长期更新
    如何用gdb工具进行调试
    检测(1)从0到1
    检测
    pytorch遇到的问题---不定期更新
    假名快速记忆
  • 原文地址:https://www.cnblogs.com/shuaitong/p/8583088.html
Copyright © 2011-2022 走看看