Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Functions

Functions

Export assignment forOwn

  • forOwn(obj: any, fcn: Function, thisArg?: any): any
  • Invokes a function once for each own enumerable property of an object.

    Notes

    • When invoked, the function is provided three arguments:

      • value: object property value
      • key: object property
      • obj: the input object
    • To terminate iteration before visiting all properties, the provided function must explicitly return false.

    • The function determines the list of own enumerable properties before invoking the provided function. Hence, any modifications made to the input object after calling this function (such as adding and removing properties) will not affect the list of visited properties.

    • Iteration order is not guaranteed.

    Parameters

    • obj: any

      input object

    • fcn: Function

      function to invoke

    • Optional thisArg: any

      execution context

    Returns any

    obj - input object

    Example

    function log( v, key ) {
        console.log( '%s: %d', key, v );
    }
    
    var obj = {
        'a': 1,
        'b': 2,
        'c': 3,
        'd': 4
    };
    
    forOwn( obj, log );