Creates a function that returns the argument at index n. Negative n counts from the end (−1 is last). Part of Lodash Util since 3.7.0 (stable — not deprecated).
Pass the arguments shown below. Prefer modular imports when you only need this helper.
Syntax
Call _.nthArg. Start with this line.
Lodash
_.nthArg([n=0])
Call
What it does
_.nthArg([n=0])
Primary signature.
_.nthArg(...)
Call the util helper.
Prefer import nthArg from "lodash/nthArg" when you want a smaller bundle.
Library declarations
Lodash
_.nthArg([n=0])
Parameters
Parameter
Description
n
Optional. Index to return (default 0); negative counts from end
Guard. Check the result if a missing arg is an error in your app.
Compatibility
Browser & Runtime Support
_.nthArg is a Lodash Util helper since 3.7.0. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 3.7.0+
_.nthArg()
Available in [email protected] full builds and the lodash/nthArg modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 3.7+
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
_.nthArgLodash 3.7.0+
Bottom line: Safe for production once Lodash is loaded. Prefer import nthArg from "lodash/nthArg" for smaller bundles.
Frequently Asked Questions
_.nthArg(n) returns a new function. When you call that function with any arguments, it returns only the argument at index n — 0 for first, 1 for second, and so on.
Yes. _.nthArg(-1) returns the last argument, _.nthArg(-2) the second-to-last — same idea as counting from the end of an array.
If you omit n, Lodash uses 0. _.nthArg() is the same as _.nthArg(0) and picks the first argument.
You get undefined. _.nthArg(2)('a', 'b') returns undefined because there is no third argument.
When an API wants a unary function but data arrives as multiple arguments — pick the one you need. Useful with _.over, _.flow, or other higher-order helpers.
No. It is a stable Lodash Util method since 3.7.0.