Javascript Array getDuplicity()
Array.prototype.getDuplicity = function() { var obj = {};/*from w ww . ja v a 2 s . com*/ var returnObj = {}; this.forEach(function(value, index) { if (!obj[value]) { returnObj[value] = 1; obj[value] = true; } else { returnObj[value]++; } }) return returnObj; }