Lodash _.divide() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Math

Definition

Divide two numbers. Part of Lodash 4.x Math (since 4.7.0).

Pass the numbers or collection shown below. Check the return value before you chain another math helper.

Syntax

Call _.divide. Start with this line.

Lodash
_.divide(dividend, divisor)
CallWhat it does
_.divide(dividend, divisor)Primary signature.
_.divide(a, b)Run the math helper on numbers or a collection.

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

Library declarations
Lodash
_.divide(dividend, divisor)

Parameters

ParameterDescription
dividendOptional. First number in the division
divisorOptional. Second number in the division

Return Value

Return ValueDescription
*Quotient, or short-circuit / default 1

Lodash Examples

Example 1 — Official Division

Divide two numbers and get a float quotient.

Lodash
_.divide(6, 4);
// → 1.5
Try It Yourself

How It Works

  1. Args. Dividend 6, divisor 4.
  2. Op. Lodash runs native / after numeric coercion.
  3. Result. 1.5 — same as the official docs.
  4. Use. Handy in pipelines next to other _. math helpers.

Example 2 — Both undefined → 1

The default for divide/multiply is the multiplicative identity.

Lodash
_.divide();
// → 1

_.divide(undefined, undefined);
// → 1
Try It Yourself

How It Works

  1. Factory. createMathOperation(…, 1) sets the empty default.
  2. Identity. 1 is the multiplicative identity (like 0 for add).
  3. Not NaN. Empty call does not become NaN.
  4. Contrast. _.add() returns 0 for the same empty case.

Example 3 — One Argument Missing

The defined value is returned without dividing.

Lodash
[
  _.divide(6, undefined),
  _.divide(undefined, 4)
];
// → [6, 4]
Try It Yourself

How It Works

  1. Short-circuit. If only one side is defined, Lodash returns it.
  2. No /. Division never runs in that branch.
  3. null ≠ undefined. null is coerced (often to 0) — different from omitting an arg.
  4. API tip. Prefer always passing two numbers in app code.

Example 4 — Divide by Zero

Same IEEE-754 result as native JavaScript — no exception.

Lodash
[
  _.divide(10, 0),
  _.divide(-10, 0),
  _.divide(0, 0)
];
// → [Infinity, -Infinity, NaN]
Try It Yourself

How It Works

  1. Positive. 10 / 0 → Infinity.
  2. Negative. -10 / 0 → -Infinity.
  3. Indeterminate. 0 / 0 → NaN.
  4. Guard. Check divisor === 0 yourself if you need an error or fallback.

Example 5 — divide vs multiply

Same factory family; opposite operations.

Lodash
[
  _.divide(6, 4),
  _.multiply(6, 4)
];
// → [1.5, 24]
Try It Yourself

How It Works

  1. divide. Runs a / b.
  2. multiply. Runs a * b.
  3. Default. Both return 1 when both args are undefined.
  4. Pick. Use the helper that matches the math you mean.

Browser & Runtime Support

_.divide is a Lodash 4.x Math helper (since 4.7.0). It uses native division after Lodash’s math-operation coercion.

✓ Stable · Lodash 4.7.0+

_.divide()

Available in [email protected] full builds and the lodash/divide modular import. Works in evergreen browsers and Node / Bun / Deno 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
_.divide Lodash 4.x+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import divide from "lodash/divide" for smaller builds.

Frequently Asked Questions

_.divide(dividend, divisor) returns the quotient of the two numbers. Official docs: _.divide(6, 4) → 1.5.
_.divide() with both undefined returns 1 — the multiplicative identity used by Lodash’s createMathOperation for divide/multiply.
The defined value is returned as-is. Example: _.divide(6, undefined) → 6 and _.divide(undefined, 4) → 4.
No. Like native JavaScript, 10 / 0 is Infinity. Lodash does not catch or rewrite that into an error.
Both share the same factory with default 1. multiply multiplies; divide divides. _.multiply(6, 4) → 24; _.divide(6, 4) → 1.5.
Use import divide from "lodash/divide" or require("lodash/divide") for tree-shaking. Full build: import _ from "lodash" then _.divide.

Next: _.floor()

Round a number down toward −Infinity with optional precision.

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