Creates a function that invokes func with arguments rearranged by an index map. The value at the first listed index becomes the first argument to func, and so on. Part of Lodash 4.x Function (since 3.0.0).
Pass the required arguments shown below. Most helpers return a new function you call later.
Syntax
Call _.rearg. Start with this line.
Lodash
_.rearg(func, indexes)
Call
What it does
_.rearg(func, indexes)
Primary signature.
_.rearg(func)
Wrap or transform a function.
Prefer import rearg from "lodash/rearg" when you want a smaller bundle.
Library declarations
Lodash
_.rearg(func, indexes)
Parameters
Parameter
Description
func
Required. Function to wrap
indexes
Required. Arrangement of argument indexes
Return Value
Return Value
Description
*
New rearranged function
Lodash Examples
Example 1 — Official: Index Map [2, 0, 1]
Pull call-site args in a custom order into the wrapped function.
Rearg reverse.[2, 1, 0] matches that reverse for three args.
Custom.[2, 0, 1] is a different permutation.
Pick. Use flip for reverse-only; use rearg for any map.
Compatibility
Browser & Runtime Support
_.rearg is a Lodash 4.x Function helper (added in 3.0.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 3.0.0+
_.rearg()
Available in [email protected] full builds and the lodash/rearg modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 3.0.0+
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
_.reargLodash 3.0.0+
Bottom line: Safe for production once Lodash 3.0.0+ is on the page or in your bundle. Prefer import rearg from "lodash/rearg" for smaller builds. For a full reverse, use _.flip.
Frequently Asked Questions
_.rearg(func, indexes) returns a new function that rearranges the arguments it receives according to indexes, then calls func. The value at indexes[0] becomes the first argument to func, indexes[1] the second, and so on.
Destination order: the nth parameter passed to func is args[indexes[n]] from the wrapper call. Example: [2, 0, 1] means func(args[2], args[0], args[1]).
_.flip reverses all arguments. _.rearg accepts any permutation — swaps, rotations, or picking a subset of slots.
Yes. Lodash accepts indexes as ...(number|number[]) — either _.rearg(fn, [2, 0, 1]) or _.rearg(fn, 2, 0, 1).
No. It returns a new wrapper. The original function is unchanged.
Use import rearg from "lodash/rearg" or require("lodash/rearg") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.rearg.