Options
All
  • Public
  • Public/Protected
  • All
Menu

Module map

Index

References

Functions Collection

References

Renames and re-exports __type

Collection Functions

  • map<T>(collection: T): Tuple<T>
  • map<T, R>(collection: ArrayLike<T>, iteratee?: ArrayIteratee<T, R>): R[]
  • map<T, R>(collection: Record<string, T>, iteratee?: RecordIteratee<T, R>): R[]
  • map(collection: any, iteratee?: any): []
  • Creates an array of values by running each element in collection thru iteratee. The iteratee is invoked with three arguments: (value, index|key, collection).

    Many lodash methods are guarded to work as iteratee for methods like every, filter, map, mapValues, reject, and some.

    The guarded methods are: ary, chunk, curry, curryRight, drop, dropRight, every, fill, invert, parseInt, random, range, rangeRight, repeat, sampleSize, slice, some, sortBy, split, take, takeRight, template, trim, trimEnd, trimStart, and words

    since

    5.0.0

    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)

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

    map(users, 'user');
    // => ['barney', 'fred']

    Type parameters

    • T: any[] | []

    Parameters

    • collection: T

    Returns Tuple<T>

  • Type parameters

    • T

    • R = any

    Parameters

    • collection: ArrayLike<T>
    • Optional iteratee: ArrayIteratee<T, R>

    Returns R[]

  • Type parameters

    • T

    • R = any

    Parameters

    • collection: Record<string, T>
    • Optional iteratee: RecordIteratee<T, R>

    Returns R[]

  • Parameters

    • collection: any
    • Optional iteratee: any

    Returns []