Get uniq nested object array with lodash

Viewed 4172

My data had nested objects with array. I want to make the nested object atrribute unique from the output. Currenly I'm using lodash v4 above, I found a solution suitable but only works in lodash v3.

Data

[{
   menu: { id: 1 },
   other: { data: "another1" }
},
{
   menu: { id: 2 },
   other: { data: "another2" }
},
{
   menu: { id: 1 },
   other: { data: "another1" }
}]

Expected output

[{
   menu: { id: 1 },
   other: { data: "another1" }
},
{
   menu: { id: 2 },
   other: { data: "another2" }
}]

Similar lodash v3 solution is here. What is the solution for v4? Solution without lodash still accepted as long as the codes are running faster and simple.

3 Answers
Related