Javascript Array detect(matcher)
Array.prototype.detect = function(matcher){ for(var i = 0; i < this.length; i++){ var item = this[i] if(matcher(item)) { return item }/*from www. j a va 2 s . c o m*/ } return null }