Lodash _.without() method

Beginner
⏱️ 6 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.without(array, ...values) clones an array while stripping explicit blacklist entries.
  • Why SameValueZero matters for NaN, signed zero, and primitive compares.
  • When _.difference() or _.pull() reads clearer than variadic without.
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Skim _.difference() for multi-array exclusion patterns—without compresses the common “omit these literals” case into a variadic tail.

  • You understand that removing objects compares references unless you add iteratees elsewhere.
  • You can open Try-it labs or run snippets locally.

Overview

_.without keeps auditing-friendly pipelines immutable—strip sentinel flags, demo accounts, or noisy primitives without rewriting consumers that still reference the untouched feed.

Blacklist literals

Pass every forbidden value as its own argument—no wrapping arrays.

Stable survivors

Earlier untouched elements keep their spacing relative to each other.

Immutable source

Original arrays remain observable for retries, logs, or Redux-style diffs.

Syntax

javascript
_.without(array, ...values)
  • array: source collection to filter.
  • values: any number of exclusions compared with SameValueZero.
  • Returns: new array omitting every matching occurrence.
1

Strip repeated primitives

Every argument is eligible for removal—duplicates in the source disappear per match without touching other numbers.

javascript
import without from "lodash/without";

without([2, 1, 2, 3], 1, 2);
// → [3]
Try it Yourself
2

NaN matches under SameValueZero

Naive === scans miss NaN; Lodash removes every noisy sentinel consistently.

javascript
import without from "lodash/without";

without([NaN, 1, NaN, 2], NaN);
// → [1, 2]
Try it Yourself
3

Objects respect reference identity

Pass the exact object reference you want stripped—structurally equal literals remain unless they share reference equality.

javascript
import without from "lodash/without";

const marker = { tag: "skip" };

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

📋 _.without vs difference, pull, reject

APIMutationBest when
_.without(array, ...values)New arraySmall literal blacklist at call site
_.difference(array, ...arrays)New arrayAnother collection already enumerates exclusions
_.pull(array, ...values)Mutates sourceIn-place cleanup with identical equality rules
_.reject(collection, predicate)New arrayRemoval logic is conditional rather than enumerative

Pitfalls to avoid

Deep

Structural equality

without will not dedupe “look-alike” objects—project ids first or jump to differenceBy/differenceWith.

Args

Accidental array wrapping

Pass scalars directly—wrapping values in an extra array makes Lodash hunt for that array object reference instead of its contents.

Perf

Huge blacklists

Very large exclusion lists scan repeatedly—consider converting exclusions to a Set with custom filtering when hotspots appear.

❓ FAQ

No. Lodash returns a new array; callers keep the original ordering of survivors while omitted matches disappear.
SameValueZero semantics—NaN matches NaN, +0 and −0 collide, and primitives compare by value.
Ordinary objects compare by reference. Pass the exact references you want stripped, or reach for differenceBy/differenceWith.
difference merges additional arrays into one exclusion set; without accepts variadic scalar arguments directly—ergonomic for literal blacklists.
Use import without from "lodash/without" or require("lodash/without") for tree-shaken bundles.

Summary

Did you know?

Think of without as the immutable twin of _.pull()—same blacklist mechanics, but your source array stays untouched for downstream readers.

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.

6 people found this page helpful