Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/for-each-right/docs/types/index.d"

Index

Functions

Functions

Export assignment forEachRight

  • 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, for forEach(), [].push() behavior is consistent with forEachRight() [].unshift() behavior.

    • When invoked, the input function is provided three arguments:

      • value: collection value
      • index: collection index
      • collection: the input collection

    Parameters

    • collection: Collection

      input collection

    • fcn: Function

      function to invoke

    • Optional thisArg: any

      execution context

    Returns Collection

    input collection

    Example

    function log( v, index, collection ) {
        console.log( '%s: %d', index, v );
    }
    
    var arr = [ 1, 2, 3, 4 ];
    
    forEachRight( arr, log );