Count duplicates within an Array of Objects

For example:

counter = {}

yourArray.forEach(function(obj) {
    var key = JSON.stringify(obj)
    counter[key] = (counter[key] || 0) + 1
})

Docs: Array.forEach, JSON.stringify.

Leave a Comment