javascript - 如何把陣列物件相同的key值合併,並且把對應的id放到一個陣列
ringa_lee
ringa_lee 2017-06-26 10:57:10
0
2
1398

例如舊資料:
var old = [

{
    id: 1,
    name: 'css',
    type: 'html'
},
{
    id: 2,
    name: 'css',
    type: 'html'
},
 {
    id: 3,
    name: 'javacript',
    type: 'code'
},
{
    id: 4,
    name: 'javacript',
    type: 'code'
}

]
想得到的 var new = [

{
    id: [1,2],
    name: 'css',
    type: 'html'
},
 {
    id: [3,4],
    name: 'javacript',
    type: 'code'
},

]
希望把相同name的物件合併,並且把對應的id放到一個陣列

ringa_lee
ringa_lee

ringa_lee

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!