<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>文档标题</title> </head> <body> <h2>去重之前:</h2> <div id="uniqueArrayBefore"></div> <h2>去重之后:</h2> <div id="uniqueArrayAfter"></div> </body> <script> var printinfos = [{ printname: "一分钱测试票", num: 1, printtime: "2021-09-27 11:09:55" }, { printname: "一分钱测试票", num: 2, printtime: "2021-09-28 11:09:55" }, { printname: "测试票", num: 5, printtime: "2021-09-28 11:09:55" }] $(function(){ $("#uniqueArrayBefore").text(JSON.stringify(printinfos)); console.log(printinfos); const res = new Map(); var printinfoArr = printinfos.filter(function(currentValue,index,arr){ if(res.has(currentValue.printname)){ for(var i = 0; i<arr.length; i++){ var obj = arr[i]; if(obj.printname === currentValue.printname){// 对象里的唯一标识printname obj.num += currentValue.num; arr[i] = obj; break; } } return false; }else{ res.set(currentValue.printname, 1); return true; } }); console.log(printinfoArr); $("#uniqueArrayAfter").text(JSON.stringify(printinfoArr)); }) </script> </html>