Array.filter

Array.filter

Array.filter

Function

Filter elements such that the callback result is true.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
callbackFnNoEmptyThe callback signature is fn(value, index, current).

Return value

TypeDescription
ArrayReturns the new filtered array.

Example

Notes

  • The original array will not be modified.