特定の条件チェックに基づいて配列から繰り返しオブジェクトを削除する必要があります この配列の同じ "connector"、 "address"、 "type"値を持つオブジェクトそのオブジェクトを削除します。配列から繰り返し出現を削除する
array = [{
connector : 'smtp',
name : 'john',
address : '[email protected]',
type : 'cc'
}, {
connector : 'smtp',
name : 'john',
address : '[email protected]',
type : 'cc'
}, {
connector : 'gtp',
name : 'mark',
address : '[email protected]',
type : 'cc'
}, {
connector : 'ftp',
name : 'wiki',
address : '[email protected]',
type : 'bcc'
},
{
connector : 'smtp',
name : 'wiki',
address : '[email protected]',
type : 'cc'
}
]
私は次のよう
output = [{
connector : 'smtp',
name : 'john',
address : '[email protected]',
type : 'cc'
},{
connector : 'gtp',
name : 'mark',
address : '[email protected]',
type : 'cc'
}, {
connector : 'ftp',
name : 'wiki',
address : '[email protected]',
type : 'bcc'
},
{
connector : 'smtp',
name : 'wiki',
address : '[email protected]',
type : 'cc'
}
]
申し訳
のような出力を必要とする私はループし、いくつかの繰り返しのforeachを試みたが、アップなしどこ終わりました。同じことをする効率的な方法を見つけるのを助けてください。
はあなたが試したコードを追加します。 – Tushar
underscore.jsライブラリに探してみてください。彼らは重複フィルタ機能を持っています。 – binariedMe