Array.prototype.filter
Array.prototype.filter is a JavaScript method that returns a new array containing the elements for which a callback predicate returns a truthy value.
Secrets of the JavaScript Ninja, Second Edition
An Array method that creates a new array containing elements that pass a callback test.
- How it is used
- Selects all array items matching a callback test, including when constructing a set intersection.
- How deep it goes
- Explains the new-array result through a worked predicate example; does not detail the callback’s full signature.
- Examples
- Filters armed ninjas from an array and intersects ninja and samurai sets to retain Hattori.
- What you can do after
- Apply it via Array.prototype.filter to collect matching array items or help construct a set intersection.
Read how Secrets of the JavaScript Ninja, Second Edition explains Array.prototype.filter →
D3.js in Action, Third Edition
The JavaScript filter() method creates a new array containing the elements that satisfy a callback condition.
- How it is used
- Selects a subset of data for a visualization, such as employees matching a Boolean property.
- How deep it goes
- Demonstrates the callback-based operation with an employee dataset, but does not discuss implementation internals or performance.
- Examples
- Uses an employee array and the works_with_d3 Boolean property to demonstrate selecting matching records.
- What you can do after
- Apply it via JavaScript to create a new array containing records that satisfy a callback condition.
Read how D3.js in Action, Third Edition explains Array.prototype.filter →
Related concepts
- arrayproduces · An array is an ordered collection of elements whose positions provide a way to access them, often across one or more dimensions.
- array methodkind of · A JavaScript array method is a built-in operation associated with arrays for inspecting, processing, or transforming their elements.
- predicateuses · A predicate is a condition or relation that can be evaluated as true or false for specified values or entities.
- array iterator methodkind of · An array iterator method is a JavaScript array method that traverses elements while producing a test result or transformed selection.
- filteringalternative to · Filtering is the processing of data or items to select, exclude, or transform them according to specified criteria or rules.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

