Lodash _.without() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Creates an array excluding all given values using SameValueZero for equality. Unlike _.pull, it returns a new array and leaves the source unchanged. Part of Lodash 4.x Array.

Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.

Syntax

Call _.without on an array. Start with this line.

Lodash
_.without(array, [values])
CallWhat it does
_.without(array, [values])Primary signature.
_.without(array)Call with an array argument.

Prefer import without from "lodash/without" when you want a smaller bundle.

Library declarations
Lodash
_.without(array, [values])

Parameters

ParameterDescription
arrayRequired. Source to inspect
valuesOptional. Zero or more values to exclude

Return Value

Return ValueDescription
*New filtered array

Lodash Examples

Example 1 — Official: Strip Listed Values

Every matching occurrence is removed; survivors stay in order.

Lodash
_.without([2, 1, 2, 3], 1, 2);
// → [3]
Try It Yourself

How It Works

  1. Source. Array is [2, 1, 2, 3].
  2. Exclude. Arguments 1 and 2 form the blacklist.
  3. Scan. Both 2s and the 1 match and drop.
  4. Keep. Only 3 remains in the new array.

Example 2 — Exclude Strings

Works the same for string primitives — all matching copies go.

Lodash
_.without(["a", "b", "c", "a"], "a");
// → ["b", "c"]
Try It Yourself

How It Works

  1. Blacklist. Only "a" is excluded.
  2. First and last. Both "a" entries are removed.
  3. Middle. "b" and "c" survive in order.
  4. Tip. Pass more strings as extra arguments to exclude several at once.

Example 3 — NaN Matches (SameValueZero)

Unlike ===, Lodash treats NaN as equal to NaN.

Lodash
_.without([1, NaN, 2, NaN], NaN);
// → [1, 2]
Try It Yourself

How It Works

  1. Problem. NaN === NaN is false in plain JS.
  2. Lodash. SameValueZero says NaN equals NaN.
  3. Result. Every NaN is stripped; 1 and 2 remain.
  4. Also. +0 and −0 are treated as the same value.

Example 4 — Objects Compare by Reference

Only the exact object instance you pass is removed — look-alikes stay.

Lodash
var marker = { tag: "skip" };

_.without([marker, "keep", marker, { tag: "skip" }], marker);
// → ["keep", { tag: "skip" }]
Try It Yourself

How It Works

  1. Shared ref. Both marker slots point to the same object.
  2. Strip. Those two slots match the exclude argument and go.
  3. Look-alike. { tag: "skip" } is a different object — it stays.
  4. Need deep match? Use _.differenceBy or _.differenceWith.

Example 5 — Empty Array & No Exclusions

Empty source yields []. Omitting exclude values returns a shallow copy of survivors.

Lodash
_.without([], 1, 2);
// → []

_.without([10, 20, 30]);
// → [10, 20, 30]
Try It Yourself

How It Works

  1. Empty. Nothing to scan → [].
  2. No values. With no exclusions, every element is kept.
  3. Still new. The result is a new array, not the same reference.
  4. Safe. Neither case throws.

Browser & Runtime Support

_.without is a Lodash 4.x Array helper. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 4.x

_.without()

Available in [email protected] full builds and the lodash/without modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.without Lodash 4.x+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import without from "lodash/without" for smaller builds. Not a native browser API — load Lodash first.

Frequently Asked Questions

_.without(array, ...values) creates a new array with all given values removed. Equality uses SameValueZero — so NaN matches NaN, and +0 equals −0.
No. It returns a new array. The source stays unchanged. Unlike _.pull, which removes values in place.
without takes exclusion values as separate arguments. difference takes one or more arrays of values to exclude. Prefer without for a small literal blacklist; prefer difference when exclusions already live in arrays.
Objects compare by reference. Pass the exact object instance you want stripped, or use _.differenceBy / _.differenceWith for custom equality.
_.without([], ...values) returns []. There is nothing to keep or remove.
Use import without from "lodash/without" or require("lodash/without") for tree-shaking. Full build: import _ from "lodash" then _.without.

Next: _.xor()

Learn symmetric difference — values that appear in an odd number of arrays.

_.xor() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful