Home » Javascript » Javascript objects comparison inside array and removing duplicates [on hold]

Javascript objects comparison inside array and removing duplicates [on hold]

Posted by: admin August 19, 2018 Leave a comment

Questions:

I have an array of objects:

var list = [
  { x: 1, value: { a: 2 }}, 
  { x: 3, value: { a: 3 }}, 
  { x: 5, value: { a: 1 }}, 
  { x: 4, value: { a: 1 }}
];

As you can see there are two equal ‘value’ objects inside this array. I need to remove a duplicate object e.g

{
  x: 4, value: { a: 1 }
}

based on value property inside the object.

Answers: