Function map

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

    Type Parameters

    • T
    • TResult

    Parameters

    • array: T[]

      The array to iterate over.

    • iteratee: ArrayIterator<T, TResult>

      The function invoked per iteration.

    Returns TResult[]

    Returns the new mapped array.

    5.0.0

    function square(n) {
    return n * n
    }

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