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