Lodash _.flip() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

Creates a function that invokes func with its arguments reversed. Useful when call sites pass values in the opposite order of your implementation. Part of Lodash 4.x Function.

Pass the required arguments shown below. Most helpers return a new function you call later.

Syntax

Call _.flip. Start with this line.

Lodash
_.flip(func)
CallWhat it does
_.flip(func)Primary signature.
_.flip(func)Wrap or transform a function.

Prefer import flip from "lodash/flip" when you want a smaller bundle.

Library declarations
Lodash
_.flip(func)

Parameters

ParameterDescription
funcRequired. Function whose args will be reversed

Return Value

Return ValueDescription
*New flipped wrapper function

Lodash Examples

Example 1 — Official: Reverse Arguments

Show the call order vs what func receives.

Lodash
var flipped = _.flip(function () {
  return _.toArray(arguments);
});

flipped("a", "b", "c", "d");
// → ["d", "c", "b", "a"]
Try It Yourself

How It Works

  1. Wrap. _.flip returns a new callable.
  2. Call. You pass a, b, c, d in that order.
  3. Reverse. Lodash reverses them before invoking func.
  4. Result. _.toArray(arguments) shows d…a.

Example 2 — Flip a Subtract Helper

Adapt (a, b) => a - b so callers can pass (b, a) style.

Lodash
function subtract(a, b) {
  return a - b;
}

var flippedSub = _.flip(subtract);

subtract(10, 3);     // → 7
flippedSub(10, 3);   // → -7  (runs as subtract(3, 10))
Try It Yourself

How It Works

  1. Original. subtract(10, 3) → 10 - 3.
  2. Flipped call. flippedSub(10, 3) becomes subtract(3, 10).
  3. Math. 3 - 10 → -7.
  4. Use. Swap call-site order without editing subtract.

Example 3 — Two-Argument Pair

Smallest useful flip: swap two parameters.

Lodash
var greet = _.flip(function (greeting, name) {
  return greeting + " " + name;
});

greet("Ada", "Hello");
// → "Hello Ada"
Try It Yourself

How It Works

  1. Call. Outer order is name, then greeting.
  2. Reverse. Inner sees greeting, then name.
  3. Join. Returns "Hello Ada".
  4. Pattern. Common when APIs disagree on parameter order.

Example 4 — Three Arguments

Flip works for any arity — all slots reverse.

Lodash
var flipped = _.flip(function (a, b, c) {
  return [a, b, c];
});

flipped(1, 2, 3);
// → [3, 2, 1]
Try It Yourself

How It Works

  1. Input. 1, 2, 3 from the caller.
  2. Reverse. Becomes 3, 2, 1 for func.
  3. Return. Array mirrors that order.
  4. Note. Middle value stays middle when arity is odd.

Example 5 — Flipped vs Original Side by Side

Same inputs, different received order.

Lodash
function collect() {
  return _.toArray(arguments);
}

var flipped = _.flip(collect);

collect("a", "b", "c");
// → ["a", "b", "c"]

flipped("a", "b", "c");
// → ["c", "b", "a"]
Try It Yourself

How It Works

  1. Original. Keeps call order.
  2. Flipped. Reverses before collect runs.
  3. Same fn. One implementation, two call conventions.
  4. Custom? Reach for _.rearg.

Browser & Runtime Support

_.flip is a Lodash 4.x Function helper. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. There is no single native flip — reverse args manually or use Lodash.

✓ Stable · Lodash 4.x

_.flip()

Available in [email protected] full builds and the lodash/flip modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.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
_.flip Lodash 4.x+

Bottom line: Safe for production once Lodash is loaded. Prefer import flip from "lodash/flip" for smaller builds. Use when you need full argument reversal without rewriting the original function.

Frequently Asked Questions

_.flip(func) returns a new function that calls func with its arguments reversed left-to-right.
No. It returns a wrapper. The original function is unchanged.
flip always reverses all arguments. _.rearg lets you pick a custom argument order.
No. Array.reverse mutates arrays. flip only reorders parameters when the wrapper is called.
When an API expects (b, a) but you wrote (a, b), or when adapting callbacks without rewriting the inner function.
The wrapper invokes func with the this of the call site (same wrap style as other Lodash helpers).

Next: _.memoize()

Cache the result of a function for repeated arguments.

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

9 people found this page helpful