Similar thing: Finds the first element by a "search lambda":
Array.prototype.find = function(search_lambda) {
return this[this.map(search_lambda).indexOf(true)];
};
Usage:
[1,3,4,5,8,3,5].find(function(item) { return item % 2 == 0 })
=> 4
Same in coffeescript:
Array.prototype.find = (search_lambda) -> @[@map(search_lambda).indexOf(true)]