Skip to content

Instantly share code, notes, and snippets.

@waystilos
Created May 25, 2015 01:20
Show Gist options
  • Save waystilos/e6fff9974fe53f7eddc4 to your computer and use it in GitHub Desktop.
Save waystilos/e6fff9974fe53f7eddc4 to your computer and use it in GitHub Desktop.
Find duplicates in array in JS
Array.prototype.numberOfOccurrences = function (a) {
var count = 0;
this.map(function (x) {
if (x === a) {
count++;
} else {
return false;
}
});
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment