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: [email protected]'},
  {id: 2, name: 'Bar Foo', email: [email protected]'},
  {id: 3, name: 'Joe Ocean', email: [email protected]'},
  {id: 3, name: 'Jenny Block', email: [email protected]'},
];

Read more