Underscore.js _.without() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Array

Definition

Returns a copy of the array with all instances of the listed values removed (official Underscore docs). Stable Array helper — not deprecated.

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

Syntax

Call _.without. Start with this line.

Underscore
_.without(array, *values)
CallWhat it does
_.without(array, *values)Primary signature.
_.without(...)Call with the arguments your case needs.

Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.

Library declarations
Underscore
_.without(array, *values)

Parameters

ParameterDescription
arrayRequired. Source to copy from
*valuesOptional. Values to remove (variadic); omit → shallow copy

Return Value

Return ValueDescription
*New array without the listed values

Underscore.js Examples

Example 1 — Official Docs Remove

Drop every 0 and every 1 from the list.

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

How It Works

  1. List exclusions. After the array, pass 0 and 1.
  2. Scan left to right. Keep values that are not 0 or 1.
  3. All copies go. Every 1 is removed, not just the first.
  4. Result. Remaining values stay in order: [2, 3, 4].

Example 2 — Remove One Value

Pass a single value to strip every occurrence of it.

Underscore
var numbers = [1, 2, 3, 4, 3];

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

How It Works

  1. Source. 3 appears twice in numbers.
  2. Call. _.without(numbers, 3) drops both.
  3. Source safe. numbers is still [1, 2, 3, 4, 3].
  4. vs splice. No in-place edits — you get a fresh array.

Example 3 — Exclude Unwanted Tags

Remove a few banned tags from a tag list in one call.

Underscore
var tags = ["js", "spam", "css", "ads", "html"];

_.without(tags, "spam", "ads");
// → ["js", "css", "html"]
Try It Yourself

How It Works

  1. Blacklist. Pass "spam" and "ads" as values to drop.
  2. Keep the rest. "js", "css", and "html" remain.
  3. Order preserved. Survivors stay in first-seen order.
  4. Spread tip. If the ban list is an array: _.without(tags, ...banned).

Example 4 — Strict Equality

Types must match — number 1 is not string "1".

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

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

How It Works

  1. Drop number 1. Both numeric ones leave; the string stays.
  2. Drop string "1". Only the string leaves; numbers stay.
  3. Objects. Two look-alike objects need the same reference to match.
  4. Normalize first if 1 and "1" should be treated the same.

Browser & Runtime Support

_.without ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.

✓ Stable · Underscore 1.x

_.without()

Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.

100% With Underscore 1.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 Underscore 1.x+

Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.without(array, *values) returns a new array with every instance of the listed values removed, keeping the rest in order.
As many as you need. _.without is variadic — list values after the array, e.g. _.without(arr, 0, 1).
Yes. If a value appears many times, all copies are removed.
With strict equality (===). Objects match by reference, so two look-alike {} values are different.
_.without takes loose values after the array. _.difference takes other arrays. Use without for a short list of literals; difference when exclusions are already in arrays.
No. It returns a new array and leaves the source unchanged.

Next: _.union()

Merge two or more arrays into one unique list in first-seen order.

_.union() 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