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

ES6 VAR, LET and CONST explained!

ES6 (ES2015) is one of the buzzwords in JavaScript nowadays. There are a lot of new features in it. Let’s watch the var, let and const!

What is a VAR?

VAR can be used for anything everywhere

The var keyword can be used everywhere. You can put in all kinds of information. Strings, Int, Object, Array, Function. That is great, well most of the time!

Variables can be used for everything, but also everywhere. You can access a var from inside a function, object, if-else statement, really everywhere! That maybe sounds cool, but can have a big effect on the performance of a website or web-application.

Globally scoped

A var is or can be globally scoped. Cool to access everything from inside anything! But is that good? With the coming of ES6 there are a few alternatives ahead. There are called let and const. They have different behavior than var. But let’s talk about that later.

Can be changed later

A variable can be defined with a string, later on, reassigned to an integer and later it could be a function. That is a power but also a weakness.

var globalVariable;

globalVariable = 'I Love Pizza!';

console.log(globalVariable); // Will be 'I Love Pizza!'

Read more