Checks whether an element in a collection passes a test.
Function invoked for each collection element while a test condition is true.
Function invoked for each collection element while a test condition is true.
Checks whether an element in a collection passes a test.
Checks whether an element in a collection passes a test.
Function invoked for each collection element while a test condition is true.
Checks whether an element in a collection passes a test.
Function invoked for each collection element while a test condition is true.
Checks whether an element in a collection passes a test.
While a test condition is true, invokes a function once for each element in a collection, iterating from right to left.
For dynamic array resizing, the only behavior made intentionally consistent with doWhileEach
(iterating from left to right) is when elements are pushed onto the beginning (end) of an array. In other words, for doWhileEach()
, [].push()
behavior is consistent with doWhileEachRight()
[].unshift()
behavior.
The condition is evaluated after executing the function to invoke; thus, the provided function always executes at least once.
When invoked, both the predicate function and the function to apply are provided three arguments:
value
: collection valueindex
: collection indexcollection
: the input collectionIf provided an empty collection, the function invokes the provided function with the collection index set to undefined
.
input collection
function to invoke
function which indicates whether to continue iterating over a collection
execution context for the applied function
input collection
function predicate( v, index, collection ) {
return ( v === v );
}
function log( v, index, collection ) {
console.log( '%s: %d', index, v );
}
var arr = [ 1, NaN, 2, 3, 4, 5 ];
doWhileEachRight( arr, log, predicate );
Function invoked for each collection element while a test condition is true.
collection value
collection index