Skip to main content

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

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

remarks

The publicly available polyfill on MDN as of mid-April, 2021 differs dramatically from the map polyfill. This implementation attempts to bridge the two.

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

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.

Parameters:#

NameTypeDescription
arrQThe input array-like to filter.
callbackArrayCBT<T, boolean>The callback provided to produce booleans. This iteratee is invoked with three arguments: value, index|key, and arr. It should return false for items to exclude.
thisArgunknownThe value to use as this when executing callback.

Returns: T[]

T[] - The filtered results.

Defined in: safe/array/filter.ts:25

Last updated on