Lodash _.add() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Math

Definition

Adds two numbers (augend + addend). Part of Lodash 4.x Math.

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

Syntax

Call _.add. Start with this line.

Lodash
_.add(augend, addend)
CallWhat it does
_.add(augend, addend)Primary signature.
_.add(a, b)Run the math helper on numbers or a collection.

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

Library declarations
Lodash
_.add(augend, addend)

Parameters

ParameterDescription
augendRequired. First number in the addition
addendRequired. Second number in the addition

Return Value

Return ValueDescription
*Sum (or concatenated string)

Lodash Examples

Example 1 — Official: Add Two Numbers

The docs baseline — six plus four.

Lodash
_.add(6, 4);
// → 10
Try It Yourself

How It Works

  1. Inputs. augend = 6, addend = 4.
  2. Numeric path. Both are numbers, so Lodash adds them.
  3. Result. 10.
  4. Use. Same idea as native 6 + 4 for plain numbers.

Example 2 — Undefined Operands

Missing values use additive-identity rules.

Lodash
_.add(undefined, 5);
// → 5

_.add(5, undefined);
// → 5

_.add(undefined, undefined);
// → 0
Try It Yourself

How It Works

  1. One missing. Return the defined operand unchanged.
  2. Both missing. Return 0 (additive identity).
  3. Why. Safe as a _.reduce iteratee when slots may be empty.
  4. Family. Multiply/divide use 1 as their both-undefined default.

Example 3 — String Concatenation

A string operand switches to concat, like native +.

Lodash
_.add(1, "2");
// → "12"

_.add("3", 4);
// → "34"

_.add(_.toNumber("3"), 4);
// → 7
Try It Yourself

How It Works

  1. Detect. Either operand is a string → concat path.
  2. Join. Values become strings and glue together.
  3. Force math. Convert with _.toNumber first.
  4. Tip. Prefer numbers when you mean arithmetic.

Example 4 — Floating-Point Quirk

Lodash does not “fix” IEEE-754 decimals.

Lodash
_.add(0.1, 0.2);
// → 0.30000000000000004

0.1 + 0.2;
// → 0.30000000000000004

_.add(0.1, 0.2) === (0.1 + 0.2);
// → true
Try It Yourself

How It Works

  1. Same math. Uses normal number addition under the hood.
  2. Binary floats. 0.1 and 0.2 are not exact in IEEE-754.
  3. Money. Scale to integer cents or use a decimal library.
  4. Expect. Identical result to native +.

Example 5 — Reduce with _.add

Handy as a two-arg callback for totals.

Lodash
_.reduce([1, 2, 3, 4], _.add);
// → 10

_.sum([1, 2, 3, 4]);
// → 10

_.subtract(10, 3);
// → 7
Try It Yourself

How It Works

  1. Reduce. Folds the array left-to-right with _.add.
  2. Sum. _.sum is clearer for “total this array.”
  3. Subtract. Sibling helper for difference.
  4. Choose. Two values → add; many values → sum.

Browser & Runtime Support

_.add is a Lodash 4.x Math helper. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native cousin: the + operator (same float math; different undefined defaults).

✓ Stable · Lodash 4.x

_.add()

Available in [email protected] full builds and the lodash/add 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
_.add Lodash 4.x+

Bottom line: Safe for production once Lodash is loaded. Prefer import add from "lodash/add" for smaller builds. Great as a pairwise adder or reduce callback.

Frequently Asked Questions

It adds augend and addend. Official example: _.add(6, 4) → 10.
If only one is undefined, Lodash returns the other unchanged. If both are undefined, it returns 0 (the additive identity).
When either operand is a string, Lodash concatenates (like native +). Force numbers with _.toNumber first.
No. _.add(0.1, 0.2) is 0.30000000000000004 — same IEEE-754 result as native +.
No. BigInt throws Cannot convert a BigInt value to a number. Use native + for BigInt.
Use _.sum(array) to total many values. Use _.add for two values or as a reducer callback.

Next: _.ceil()

Round a number up toward +Infinity with optional precision.

_.ceil() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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