Javascript Array first(matching)
Array.prototype.first = function(matching) { for (var i = 0; i < this.length; i++) { var entry = this[i]; //from ww w. j av a 2 s .c o m if (matching(entry) == true) return this[i]; } return null; }