Constant. Builds a function that will return 10 later.
Types differ. One is the value; the other is a wrapper.
Rule. Need the value now → identity. Need a fixed callback → constant.
Compatibility
Browser & Runtime Support
_.identity 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
_.identity()
Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.
100%With Underscore 1.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
_.identityUnderscore 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
_.identity(value) returns the same value you pass in. In math that is f(x) = x. Example: stooge === _.identity(stooge) is true.
var stooge = {name: 'moe'}; stooge === _.identity(stooge) returns true. identity does not copy the object — it returns the original reference.
It looks useless alone, but Underscore uses it as the default iteratee. When a callback is omitted or null, identity is what runs: each item passes through unchanged.
identity returns the same reference. A clone is a new object. stooge === _.identity(stooge) is true; after cloning, that comparison would be false.
identity returns whatever you pass in this call. _.constant(value) returns a function that always yields that fixed value later and ignores later arguments.
No. It is a stable Underscore utility kept around for default iteratees. You can also use it as a truthy filter predicate.