_.find

find_.find(list, predicate, [context]) Alias: detect
Looks through each value in the list, returning the first one that passes a truth test (predicate), or undefined if no value passes the test. The function returns as soon as it finds an acceptable element, and doesn't traverse the entire list.

var even = _.find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
=> 2
doc_Underscore
2016-04-09 09:05:21
Comments
Leave a Comment

Please login to continue.