我将多个数组连接到一个数组。这个效果很好
\n\nthis.facetsLocations = [].concat(\n response.facets[\'134_locations\'].terms,\n response.facets[\'135_locations\'].terms\n );\nRun Code Online (Sandbox Code Playgroud)\n\n但输出不是我想要的。正如你所看到的,我有相同的术语,如“deutschland”,计数:6\n“deutschland”,计数:4 等等。
\n\n结果应该是一个“deutschland”,计数 10\ni 想检查该值是否已存在并添加计数值。
\n\n(11) [{\xe2\x80\xa6}, {\xe2\x80\xa6}, {\xe2\x80\xa6}, {\xe2\x80\xa6}, {\xe2\x80\xa6}, {\xe2\x80\xa6}, {\xe2\x80\xa6}, {\xe2\x80\xa6}, {\xe2\x80\xa6}, {\xe2\x80\xa6}, {\xe2\x80\xa6}]\n0: {term: "deutschland", count: 6}\n1: {term: "basel", count: 3}\n2: {term: "osteuropa", count: 2}\n3: {term: "\xc3\xb6sterreich", count: 1}\n4: {term: "ungarn", count: 1}\n5: {term: "schweiz", count: 1}\n6: {term: "basel", count: 5}\n7: {term: "deutschland", count: 4}\n8: {term: "\xc3\xb6sterreich", count: 1}\n9: {term: "ungarn", count: 1}\nRun Code Online (Sandbox Code Playgroud)\n