Iterates a collection and returns a new array of every element whose predicate is truthy. Unlike _.remove, it does not mutate the source. Part of Lodash 4.x Collection (since 0.1.0).
Pass the required arguments shown below. Lodash Collection helpers usually return a new value — check whether the source is mutated.
Syntax
Call _.filter on a collection. Start with this line.
Lodash
_.filter(collection, [predicate=_.identity])
Call
What it does
_.filter(collection, [predicate=_.identity])
Primary signature.
_.filter(collection)
Call with a collection argument.
Prefer import filter from "lodash/filter" when you want a smaller bundle.
_.filter is a Lodash 4.x Collection helper (since 0.1.0). It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native Array.prototype.filter covers arrays only; Lodash also walks plain objects and offers iteratee shorthands.
✓ Stable · Lodash 4.x
_.filter()
Available in [email protected] full builds and the lodash/filter modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.filterLodash 4.x+
Bottom line: Safe for production once Lodash is loaded. Prefer import filter from "lodash/filter" for smaller builds. Ideal for search results, status lists, and UI table filters.
Frequently Asked Questions
_.filter(collection, predicate) returns a new array of every element for which predicate is truthy. Order matches collection order.
No. Unlike _.remove, filter always returns a new array and leaves the source unchanged.
An array of matching values — not an object. Keys are not preserved in the result shape.
filter keeps truthy predicate results. reject keeps falsey ones — the complement with the same iteratee.
partition returns [pass, fail] in one pass. filter only returns the pass list.
Use import filter from "lodash/filter" or require("lodash/filter") for tree-shaking. Full build: import _ from "lodash" then _.filter.