Skip to main content

add()

add(augend, addend): number

Adds two numbers.

DEPRECATED

Use the + operator directly instead.


Parametersโ€‹

augend: numberโ€‹

The first number in an addition.

addend: numberโ€‹

The second number in an addition.


Returns: numberโ€‹

The sum.


See Alsoโ€‹

Addition (+) - MDN


Sinceโ€‹

2.0.0


Also known asโ€‹

add (Lodash, Ramda) ยท โŒ (es-toolkit, Remeda, Radashi, Effect, Modern Dash, Antfu)


Exampleโ€‹

// โŒ Deprecated approach
add(6, 4); // => 10

// โœ… Recommended approach
6 + 4; // => 10

How it works?โ€‹

Adds two numbers. Deprecated: Use the + operator directly.

Native Equivalentโ€‹

// โŒ add(6, 4)
// โœ… 6 + 4

Use Casesโ€‹

Add numbers ๐Ÿ“Œโ€‹

Add two numbers.

a + b;

Accumulate valuesโ€‹

Sum array of numbers.

const total = numbers.reduce((a, b) => a + b, 0);