instance method Enumerable#detect
Enumerable#detect(iterator[, context]) → firstElement | undefined
-
iterator(Function) – The iterator function to apply to each element in the enumeration. -
context(Object) – An optional object to use asthiswithin calls to the iterator.
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
Aliased as: Enumerable#find