Lodash Math Methods

Beginner
5 min read
Updated: Nov 2026
15 method guides
Method index

About This Index

This page is the Lodash Math index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.

Learn lang checks on /lodash/lang. Use this page when you need math helpers such as _.add(), _.round(), or _.sum().

Beginner path.

Start with _.add(), then _.round(), _.max(), and _.sum()—then open the *By variants for object arrays.

How to Call a Math Method

Pass numbers (or an array for aggregators) to the Lodash helper:

Lodash
import _ from "lodash";

_.add(6, 4);           // 10
_.subtract(6, 4);      // 2
_.multiply(6, 4);      // 24
_.divide(6, 4);        // 1.5

_.round(4.006, 2);     // 4.01
_.ceil(6.004, 2);      // 6.01
_.floor(0.046, 2);     // 0.04

_.max([4, 2, 8, 6]);   // 8
_.sum([4, 2, 8, 6]);   // 20
_.mean([4, 2, 8, 6]);  // 5

_.maxBy([{ n: 1 }, { n: 2 }], "n"); // { n: 2 }

Lodash Math Methods Table

All math method guides in this Lodash tutorial series (15 tutorials).

Arithmetic

4 methods

Add, subtract, multiply, and divide two numbers.

MethodDescriptionTutorial
_.add()Add two numbers. Undefined operands are treated as 0.Try it
_.subtract()Subtract the second number from the first. Undefined operands are treated as 0.Try it
_.multiply()Multiply two numbers. Undefined operands are treated as 1.Try it
_.divide()Divide two numbers. Undefined operands are treated as 1.Try it

Rounding

3 methods

Ceil, floor, and round with optional precision.

MethodDescriptionTutorial
_.ceil()Round a number up. Supports precision, including negative precision.Try it
_.floor()Round a number down. Supports precision, including negative precision.Try it
_.round()Round a number. Supports precision; negative precision rounds to tens/hundreds.Try it

Min & Max

4 methods

Find extremes in an array, optionally by iteratee.

MethodDescriptionTutorial
_.max()Largest element in an array. Returns undefined when the array is empty.Try it
_.maxBy()Like max, but each element is ranked by an iteratee.Try it
_.min()Smallest element in an array. Returns undefined when the array is empty.Try it
_.minBy()Like min, but each element is ranked by an iteratee.Try it

Aggregate

4 methods

Sum and mean over arrays, with iteratee variants.

MethodDescriptionTutorial
_.sum()Sum of an array of numbers. Returns 0 when the array is empty.Try it
_.sumBy()Like sum, but each element is projected by an iteratee before adding.Try it
_.mean()Arithmetic mean of an array of numbers. Returns NaN when empty.Try it
_.meanBy()Like mean, but each element is projected by an iteratee first.Try it

Frequently Asked Questions

Fifteen helpers for arithmetic (_.add, _.subtract, _.multiply, _.divide), rounding (_.ceil, _.floor, _.round), extremes (_.max, _.min), and aggregates (_.sum, _.mean)—plus *By iteratee variants.
Arithmetic helpers treat undefined as identity values (0 for add/subtract, 1 for multiply/divide), so they work well inside _.reduce. Empty arrays return undefined for max/min, 0 for sum, and NaN for mean—not ±Infinity.
Ceil, floor, and round accept a precision argument. Positive precision keeps decimal places; negative precision rounds to tens, hundreds, and beyond (for example, _.round(4060, -2) → 4100).
Prefer per-method imports: import sum from 'lodash/sum' or import { sum } from 'lodash-es'. You can also use const _ = require('lodash') and call _.sum().
Start with _.add(), then _.round(), _.max(), and _.sum() from the table below.

Start with _.add()

Open the addition guide—syntax, examples, and FAQs.

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

10 people found this page helpful