Function map

  • Creates an array of values by running each element in collection thru iteratee. The iteratee is invoked with three arguments: (value, index|key, collection).

    Example

    function square(n) {
    return n * n
    }

    map([4, 8], square)
    // [16, 64]

    map({ a: 4, b: 8 }, square)
    // [16, 64] (iteration order is not guaranteed)

    let users = [
    { user: 'barney' },
    { user: 'fred' }
    ]

    // The `property` iteratee shorthand.
    map(users, 'user')
    // ['barney', 'fred']

    Returns

    Returns the new mapped array.

    See

    Array.map()

    Type Parameters

    • T

    • TResult

    Parameters

    • arr: T[]

      The collection to iterate over.

    • fn: Iteratee<T, PropertyKey, TResult>

      The function invoked per iteration.

    Returns TResult[]

  • Type Parameters

    • T

    • TResult

    Parameters

    • arr: T[]
    • fn: PropertyKey

    Returns TResult[]

  • Type Parameters

    • T

    • TResult

    Parameters

    • arr: Object
    • fn: Iteratee<T, PropertyKey, TResult>

    Returns TResult[]

  • Type Parameters

    • T

    • TResult

    Parameters

    • arr: Object
    • fn: PropertyKey

    Returns TResult[]

Generated using TypeDoc