Javascript Array numberOfOccurrences(number)
Array.prototype.numberOfOccurrences = function (number) { return this.reduce(function (previous, current) { return (current === number) ? ++previous : previous; }, 0);/*from www. j ava 2 s . co m*/ };