JavaScript Math exp()

The JavaScript Math.exp() function returns e (Euler's number) raised to given power.

It is equivalent to ex in mathematics.

The syntax of the Math.exp() function is:

Math.exp(x)

exp(), being a static method, is called using the Math class name.


Math.exp() Parameters

The Math.exp() function takes in:

  • x - A number

Return value from Math.exp()

  • Returns ex for argument x, where e is Euler's number (2.71828).

Example: Using Math.exp()

// Math.exp() is equivalent e**x

var value = Math.exp(0);
console.log(value); // 1

var value = Math.exp(1);
console.log(value); // 2.718281828459045

var value = Math.exp("-1");
console.log(value); // 0.36787944117144233

var value = Math.exp(2);
console.log(value); // 7.38905609893065

var value = Math.exp(5);
console.log(value); // 148.4131591025766

Output

1
2.718281828459045
0.36787944117144233
7.38905609893065
148.4131591025766

Note: Use the constant Math.E to get the approximate value of e.


Recommended readings: