Find duplicate property values in an Array of Objects in JavaScript

Finding duplicate property values in an Array of Objects in JavaScript is not always that simple if you thought, so let’s dive in! A few days ago I needed to work this out, so I thought let’s write it down, so I could use it later again!

Array of Objects

Let’s define an example Array of Objects, where each Object is a user:

var myArray = [
  {id: 1, name: 'Foo Bar', email: 'foo@bar.com'},
  {id: 2, name: 'Bar Foo', email: 'bar@foo.com'},
  {id: 3, name: 'Joe Ocean', email: 'joe@ocean.com'},
  {id: 3, name: 'Jenny Block', email: 'foo@bar.com'},
];

Read more