朕有一个数组对象,结构是这样的:
[JavaScript] 纯文本查看 复制代码 [
{id: "2a0398605f1c160f0072498e5f4942e6", region: "茂名"},
{id: "9bf625a55f1c1616006bed846372e6e3", region: "电白"},
{id: "f47f682c5f1c163f008839ef2a343440", region: "茂名"},
{id: "3d23c0a05f1c1681008a5b3a0b8bb446", region: "茂名"},
{id: "f47f682c5f1c168c00883c273a954b1e", region: "茂南"},
{id: "08e51e265f1c16910070c8117bbe476c", region: "茂名"},
{id: "15d399db5f1c16ef0086f16b2a83a752", region: "茂名"},
{id: "08e51e265f1c1b340070e7675a7c02df", region: "茂名"},
{id: "9bf625a55f1c1b40006c0e721d7a7690", region: "高州"},
{id: "9bf625a55f1c1b44006c0e916570035a", region: "高州"},
{id: "3d23c0a05f1c1b52008a840d3b62a411", region: "高州"},
{id: "2a0398605f1c1b5600726d490bf434c9", region: "化州"},
]
朕希望对region进行统计,输出这样的结果:
[JavaScript] 纯文本查看 复制代码 {茂名:6,电白:1,茂南:1,高州:3,化州:1}
怎样统计比较科学?诸王有何高见,请指教,谢谢
|