all :: Enumerable

all([iterator = Prototype.K]) -> Boolean

 

Determines whether all the elements are boolean-equivalent to true, either directly or through computation by the provided iterator.

 

The code obviously short-circuits as soon as it finds an element that “fails” (that is boolean-equivalent to false). If no iterator is provided, the elements are used directly. Otherwise, each element is passed to the iterator, and the result value is used for boolean equivalence.

 

Examples

 

[].all()

// -> true (empty arrays have no elements that could be false-equivalent)

 

$R(15).all()

// -> true (all values in [1..5] are true-equivalent)

 

[012].all()

// -> false (with only one loop cycle: 0 is false-equivalent)

 

[91015].all(function(n) { return n >= 10; })

// -> false (the iterator will return false on 9)

 

$H({ name: 'John', age: 29, oops: false }).all(function(pair) { return pair.value; })

// -> false (the oops/false pair yields a value of false)

 

See also

 

If you need to determine whether at least one element matches a criterion, you would be better off using any.

 

Enumerable: any


Prototype API 1.5.0 - prototypejs.org