Javascript Array count(filter)
Array.prototype.count = function(filter) { var ct = 0;//w w w . j a va 2 s . c o m for (var i = 0; i< this.length; i++) { if(filter(this[i])){ ct++; } } return ct; }