For dynamic array resizing, the only behavior made intentionally consistent with forEach (iterating from left to right) is when elements are pushed onto the beginning (end) of an array. In other words, for forEach(), [].push() behavior is consistent with forEachRight()[].unshift() behavior.
When invoked, the input function is provided three arguments:
Invokes a function once for each element in a collection, iterating from right to left.
Notes
For dynamic array resizing, the only behavior made intentionally consistent with
forEach
(iterating from left to right) is when elements are pushed onto the beginning (end) of an array. In other words, forforEach()
,[].push()
behavior is consistent withforEachRight()
[].unshift()
behavior.When invoked, the input function is provided three arguments:
value
: collection valueindex
: collection indexcollection
: the input collection