Underscore.js _.noop() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Utility

Definition

An empty function that returns undefined irrespective of the arguments passed to it (official Underscore docs).

Pass the required arguments shown below. Underscore utility helpers usually return a new value or function — check edge cases before you ship.

Syntax

Call _.noop. Start with this line.

Underscore
_.noop() or pass _.noop
CallWhat it does
_.noop() or pass _.noopPrimary signature.
_.noop(...)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
_.noop() or pass _.noop

Parameters

This method has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*Always undefined

Underscore.js Examples

Example 1 — Official Initialize Stub

Assign _.noop as a placeholder method. Calling it returns undefined.

Underscore
var obj = {};
obj.initialize = _.noop;

typeof obj.initialize;
// → "function"

obj.initialize();
// → undefined
Try It Yourself

How It Works

  1. Start empty. obj has no methods yet.
  2. Assign the reference. obj.initialize = _.noop (no parentheses).
  3. It is a function. typeof reports "function".
  4. Call it. The empty body runs; the result is undefined.

Example 2 — Arguments Are Ignored

Call it empty or with values. The return is always undefined.

Underscore
_.noop();
// → undefined

_.noop(1, 2, 3);
// → undefined

_.noop("hi");
// → undefined
Try It Yourself

How It Works

  1. No args. Still returns undefined.
  2. Many args. They are accepted and discarded.
  3. Strings too. Input never becomes the return value.
  4. Rule. Noop never echoes arguments — that is _.identity.

Example 3 — Optional Callback Default

Use callback || _.noop so you can always call the hook safely.

Underscore
function greet(onReady) {
  onReady = onReady || _.noop;
  return onReady("hi");
}

greet();
// → undefined

greet(_.identity);
// → "hi"
Try It Yourself

How It Works

  1. Default the hook. Missing onReady becomes _.noop.
  2. Always call it. No if (onReady) branch needed.
  3. Silent path. greet() returns undefined.
  4. Real callback. Pass _.identity and you get "hi" back.

Example 4 — _.noop vs Identity vs Constant

Same input, three helpers, three answers.

Underscore
_.identity(7);
// → 7

_.constant(7)();
// → 7

_.noop(7);
// → undefined
Try It Yourself

How It Works

  1. Identity. Returns the argument 7.
  2. Constant. Builds a function that yields 7 when called.
  3. Noop. Ignores 7 and returns undefined.
  4. Pick by intent. Pass-through → identity. Fixed value → constant. Do nothing → noop.

Browser & Runtime Support

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

✓ Stable · Underscore 1.7+

_.noop()

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

100% With Underscore 1.7+
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
_.noop Underscore 1.7+

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

_.noop is an empty function. It ignores every argument and always returns undefined. Underscore’s docs say it is useful as the default for optional callback arguments.
obj.initialize = _.noop assigns the empty function as a placeholder method. Calling obj.initialize() returns undefined and does no work.
Usually _.noop — the function reference. Parentheses call it immediately and give you undefined, not something you can call later. Write callback = callback || _.noop, not callback = _.noop().
identity returns the argument. constant(value) returns a function that always yields that value. noop ignores arguments and always returns undefined.
Use it when an API requires a function but you have nothing to do: optional callbacks, stub methods like initialize, or an iteratee that should produce undefined.
No. It is a stable Underscore utility added in version 1.7.0 as a handy empty placeholder function.

Next: _.times()

Learn how to call a function a fixed number of times and collect the results.

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