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 the Number type for which we want to find the exp().

Number in JavaScript is a 64-bit double-precision value which is the same as double in C# or Java.

Return value

  • Number: It returns a number that represents e^param where param is the input parameter. It is of the Number type.

  • Infinity: The function returns this if input param is equal to Infinity.

e is 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));

Free Resources