It is equivalent to ex - 1 in mathematics.
The syntax of the Math.expm1()
function is:
Math.expm1(x)
expm1()
, being a static method, is called using the Math
class name.
Math.expm1() Parameters
The Math.expm1()
function takes in:
- x - A number
Return value from Math.expm1()
- Returns ex - 1 for argument x, where e is Euler's number (2.71828).
Example: Using Math.expm1()
// Math.expm1() is equivalent to e**x-1
var value = Math.expm1(0);
console.log(value); // 0
var value = Math.expm1(1);
console.log(value); // 1.718281828459045
var value = Math.expm1("2");
console.log(value); // 6.38905609893065
var value = Math.expm1(-1);
console.log(value); // -0.6321205588285577
Output
0 1.718281828459045 6.38905609893065 -0.6321205588285577
Note: Use the constant Math.E
to get the approximate value of e.
Recommended readings: