Elementals.js

Latest Version: 3.7 Final 20 December 2018

Method Array.callbackOr

Summary:

Iterates through an array passing a core element and the array indexed value to a callback, performing a logical or of all callback results.

Calling Convention:
Array.callbackOr(Element, callback)
Parameters:
Element
An element passed to the callback
callback
The callback function to be called. Should return a boolean true or false.
Returns:
True if any single callback returned true
False if ALL callback returned false

Example -- recursivly check for and add class names from array

JavaScript

function classAdd(element, names) {
	if (names instanceof Array)
		return names.callbackOr(element, classAdd);
	if (!classExists(element, names)) {
		element.className += (element.className ? ' ' : '') + names;
		return true;
	}
	return false;
}

Elementals Array Methods

Elementals Extensions

Polyfills

These link to the Mozilla Developer Network (MDN)

Property Key

  • Object
  • Method or Variable
  • "Constant" Variable

Downloads

Advertisement