Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

first_result

oatkiller edited this page Sep 13, 2010 · 2 revisions

first_result iterates over an array or object, passing each element / property to a fn you provide. first_result returns the first truthy result from your fn.

first_result is similar to find. the difference is that find returns the element, and first_result returns the return of the fn

(function () {

// get a number

// returns 3
['blah','ducks','3','woot'][o.first_result](function (n) {
	return parseFloat(n);
}); 

})();
Clone this wiki locally