Skip to content
Advertisement

How to remove duplicates by property of an object in an array of objects and copy all properties of duplicates?

I delete all duplicates by the “sourceType” property of the object in the array of objects, but I cannot copy the “dataType” property from the duplicates to the original, please check what I’ expecting in at output and expected output

JavaScript

output:

JavaScript

expected output:

JavaScript

Advertisement

Answer

You need to group the items by sourceType and collect dataType for every group.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement