The Wayback Machine - https://web.archive.org/web/20250401011055/https://www.geeksforgeeks.org/javascript-math-exp-method/
Open In App

JavaScript Math exp() Method

Last Updated : 15 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

The JavaScript Math exp( ) Method is used to return ex, where x is the argument, and e is Euler’s number, which is the base of the natural logarithms. The exp() is a static method of Math, therefore, it is always used as Math.exp(), rather than as a method of a Math object created.

Syntax:  

Math.exp(value)

Parameters:

This function accepts a single parameter as mentioned above and described below:  

  • Value is a number whose ex you want to find.

Return Value:

  • The Math.exp() method returns ex where e is Euler’s number and x is the argument.

Example 1: Below is an example of the Math exp() Method. 

JavaScript
console.log("When zero is passed as a parameter: "
    + Math.exp(0));

Output
When zero is passed as a parameter: 1

Example 2: When “-1” is passed as a parameter.

JavaScript
console.log("Result : " + Math.exp(-1));

Output
Result : 0.36787944117144233

Example 3: When “1” is passed as a parameter. 

JavaScript
console.log("Result : " + Math.exp(1));

Output
Result : 2.718281828459045

We have a complete list of Javascript Math Objects methods, to check those please go through this Javascript Math Object Complete reference article.

Supported Browsers: 

  • Chrome 51
  • Edge 15
  • Firefox 54
  • Safari 10
  • Opera 38

JavaScript Math exp() Method – FAQs

What does the Math.exp() method do in JavaScript?

The Math.exp() method returns e (Euler’s number, approximately 2.718) raised to the power of a given number.

How does Math.exp() handle non-numeric arguments?

If the argument is not a number, Math.exp() first attempts to convert it to a number. If the conversion is not possible, the result is NaN (Not-a-Number).

Can Math.exp() handle special numeric values like NaN, Infinity, and -Infinity?

  • Math.exp(NaN) returns NaN.
  • Math.exp(Infinity) returns Infinity.
  • Math.exp(-Infinity) returns 0.

What are common use cases for the Math.exp() method?

  • Exponential Growth Calculations: Using Math.exp() to model exponential growth or decay in finance, biology, and physics.
  • Scientific Calculations: Implementing formulas and algorithms that require the exponential function.

How can Math.exp() be used with variables?

Math.exp() can be used with variables that hold numeric values. For example: Math.exp(x) where x is a variable containing a number.

We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.


Next Article

Similar Reads

three90RightbarBannerImg