API · JavaScript

JavaScript Math.exp(x) Method

In JavaScript, the Math.exp(x) method considers x as the number used to power e. e is the Euler's number, approximately 2.7183. This method returns the value of 2.7183 raised to a power (x).

On this page

The Math.exp(x) method is used to get the value of the number e raised to a power (x). Here x is the given number, and e is 2.7183, considered the base of the natural logarithms.

Syntax of JavaScript Math.exp(x):

Math.exp(x);

Parameters

x The number that will be considered the power of e. Here, e is the base of natural logarithms.

Return

This method returns the value of e raised to a power (x).

Example Code: Use the Math.exp(x) Method to Get the Exponential Value of a Number

We can use the Math.exp(x) method to get a value of e raised to power x. In this example, we used the Math.exp(x) method to get the value of a number.

const x = 4;
let exp = Math.exp(x);
console.log(exp);

Output:

54.598150033144236

Example Code: Use the Math.exp(x) Method to Experiment and Find Value of the Different Numbers

The Math.exp(x) method allows the multiplication method to get a similar result. We can use the Math.exp(x) method to get the same result as Math.exp(y)*Math.exp(z), if x is equal to y+z.

In this example, we have used the multiplication method to get the output of Math.exp(x).

let exp = Math.exp(2) * Math.exp(3);
let e = Math.exp(5);
console.log(exp);
console.log(e);

Output:

148.4131591025766
148.4131591025766

In the above output, users can see that Math.exp(2)*Math.exp(3) gives the same result as Math.exp(5) because of 2+3=5.

The Math.exp(x) method is supported in all browsers. In the Math.exp(x) method, Math is considered a placeholder object that includes all the mathematical functions.