instance method Array#filter

View source on GitHub →

Array#filter(iterator[, context]) → Array
  • iterator (Function) – An iterator function to use to test the elements.
  • context (Object) – An optional object to use as this within calls to the iterator.

Returns a new array containing all the items in this array for which iterator returned a truthy value.

Array#filter acts as an ECMAScript 5 polyfill. It is only defined if not already present in the user's browser, and it is meant to behave like the native version as much as possible. Consult the ES5 specification for more information.