Skip to main content

map<Q, T, R>(arr: Q, callback?: ArrayCBT<T, R>, thisArg?: unknown): R[]

A more-or-less spec-compliant Array map.

remarks

Certain steps in the spec have been omitted through the use of es6 features or for performance. This implementation outperforms built-in .map but runs measurably worse than other non-spec-compliant solutions out there. If you are looking for raw speed, use the unsafe version of mapip, which outperforms everybody.

see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

Type parameters:#

NameTypeDefaultDescription
Qunknownunknown[]The type of the array-like being provided.
T-Q[keyof Q]The type of elements in the array-like being provided.
R-TThe return value of the provided callback, and thus, type of resulting array elements.

Parameters:#

NameTypeDescription
arrQThe input array-like to map through.
callbackArrayCBT<T, R>The callback provided to produce mapped results. This iteratee is invoked with three arguments: value, index|key, and arr.
thisArgunknownThe value to use as this when executing callback.

Returns: R[]

R[] - The new mapped array.

Defined in: safe/array/map.ts:26

Last updated on