可以說我有地圖就像一個列表:組列表
var x = [{"name":"Not1","type":"Email"},{"name":"Not2","type":"Instant"},{"name":"Not3","type":"Email"},{"name":"Not4","type":"Instant"}]
我所要的輸出是:
var result = {"Email":[{"name":"Not1","type":"Email"}, {"name":"Not3","type":"Email"}],"Instant":[{"name":"Not2","type":"Instant"}, {"name":"Not4","type":"Instant"}]}
我怎樣才能以最好的方式做到這一點?在此先感謝
使用循環。這實際上是相當微不足道的,沒有什麼魔法可以進一步簡化它。嘗試一下並向我們展示你的嘗試。 – Bergi