Javascript Array countItem(item)
Array.prototype.countItem = function (item) { return this.filter(function (i) { return i === item }).length;//from w w w . java 2 s . c o m };