What is Math.expm1() in JavaScript?
Math is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations. It contains the expm1() function, which is used to compute e raised to the power of a specified number - 1.
Syntax
Math.expm1(param);
Parameter
param: This is the input value of typeNumberfor which we want to find theexpm1().
Numberin JavaScript is a 64-bit double-precision value which is the same asdoublein C# or Java.
Return value
-
Number: It returnse^param- 1 whereparamis the input value. It is of typeNumber. -
Infinity: The function returns this if inputparamis equal toInfinity.
eis called the Euler number, and has a value of approximately 2.71828.
Example
console.log("expm1(-1) = " + Math.expm1(-1));console.log("expm1(0) = " + Math.expm1(0));console.log("expm1(∞) = " + Math.expm1(Infinity));console.log("expm1(2) = " + Math.expm1(2));console.log("expm1(-2) = " + Math.expm1(-2));console.log("expm1(e) = " + Math.expm1(Math.E));console.log("expm1(1) = " + Math.expm1(1));