doc: merge old docs for Enumerable#detect, add example

This commit is contained in:
tjcrowder 2009-09-07 14:12:55 +01:00 committed by Tobie Langel
parent f1c8c1e266
commit 23ebc851b1
1 changed files with 10 additions and 1 deletions

View File

@ -225,9 +225,18 @@ var Enumerable = (function() {
/**
* Enumerable#detect(iterator[, context]) -> firstElement | undefined
* - iterator (Function): The iterator function to apply to each element
* in the array.
* - context (Object): An optional object to use as `this` within
* calls to the iterator.
*
* Finds the first element for which the iterator returns a "truthy" value.
* Returns the first element for which the iterator returns a truthy value.
* Aliased by the [[Enumerable#find]] method.
*
* ### Example
*
* [1, 7, -2, -4, 5].detect(function(n) { return n < 0; })
* // -> -2
**/
function detect(iterator, context) {
var result;