fluid.find(list, fn, deflt)
Scans through a list of objects, terminating on and returning the first member which matches a predicate function.
fluid.find(list, fn, deflt);
File name: Fluid.js
Parameters
list |
(Arrayable|Object) The list or hash of objects to be searched. |
fn |
(Function) A predicate function, acting on a list member. A predicate which returns any value which is not null or undefined will terminate the search. The function has the signature (object, index). |
deflt |
(Object) (optional) A value to be returned in the case no predicate function matches a list member. The default will be the natural value of undefined |
Return Value
Object | the first object in the list that matches the predicate function, or deflt if nothing does |
See Also
Example
var findColIndex = function (item, layout) { return fluid.find(layout.columns, function (column, colIndex) { return item === column.container? colIndex : undefined; }); };
The function findColIndex
uses fluid.find
to examine a list of columns. The anonymous function being passed as the second argument examines each column's container
property and returns the index of the column if found.