subtract()
subtract(
minuend,subtrahend):number
Subtracts two numbers.
DEPRECATED
Use the - operator directly instead.
Parametersโ
minuend: numberโ
The first number in a subtraction.
subtrahend: numberโ
The second number in a subtraction.
Returns: numberโ
The difference.
See Alsoโ
Sinceโ
2.0.0
Also known asโ
subtract (Lodash, Ramda) ยท โ (es-toolkit, Remeda, Radashi, Effect, Modern Dash, Antfu)
Exampleโ
// โ Deprecated approach
subtract(6, 4); // => 2
// โ
Recommended approach
6 - 4; // => 2
How it works?โ
Subtracts two numbers.
Deprecated: Use the - operator directly.
Native Equivalentโ
// โ subtract(6, 4)
// โ
6 - 4
Use Casesโ
Subtract numbers ๐โ
Subtract two numbers.
a - b;
Calculate differenceโ
Calculate change between values.
const change = newValue - oldValue;
const percentChange = (change / oldValue) * 100;