Method Array.callbackAnd
Summary:
Iterates through an array passing a core element and the array indexed value to a callback, aborting the loop when a callback returns false.
- Calling Convention:
-
Array.callbackAnd(Element, callback)
- Parameters:
-
- Element
- An element passed to the callback
- callback
- The callback function to be called. Should return a boolean true or false. When a false is returned by the callback, iterating the array will cease.
- Returns:
- True if all Array elements were parsed
- False if a callback returned loose false and execution was halted.
Example -- recursive search for class name
JavaScript
function classExists(element, names) {
if (names instanceof Array)
return names.callbackAnd(element, classExists);
return RegExp('(\\s|^)' + n + '(\\s|$)').test(e.className);
}