JavaScript | Math.E() function
The Math.E() is an inbuilt function in JavaScript which is used to get the value of ep, where p is any given number.
The number e is a mathematical constant having an approximate value equal to 2.718.
- It was discovered by the Swiss mathematician Jacob Bernoulli.
- This number is also called Euler’s number.
Syntax:
Math.exp(p)
Parameter: This funcion accepts a sinlge parameter p is any number.
Return Value: It return the value of ep, where p is any given number as parameter.
Example:
Input : Math.exp(0) Output : 1
Explanation:
Here the value of parameter p is 0, So after putting the value 0 instead of p in ep
then its value becomes 1.
Input : Math.exp(2) Output : 7.38905609893065
Explanation:
Here the value of parameter p is 2, So after putting the value 2 instead of p in ep
then its value becomes 7.38905609893065.
Let’s see JavaScript program:
<script> // Here different values is being taken as // as parameter of Math.exp() function. document.write(Math.exp(0) + "<br>"); document.write(Math.exp(1) + "<br>"); document.write(Math.exp(2) + "<br>"); document.write(Math.exp(-1) + "<br>"); document.write(Math.exp(-7) + "<br>"); document.write(Math.exp(10) + "<br>"); document.write(Math.exp(1.2)); </script> |
Output:
1 2.718281828459045 7.38905609893065 0.36787944117144233 0.0009118819655545162 22026.465794806718 3.3201169227365472
<script> // Here alphabet parameter give error. document.write(Math.exp(a)); </script> |
Output:
Error: a is not defined
<script> // Here parameter as a string give NaN. document.write(Math.exp("gfg")); </script> |
Output:
NaN
Supported Browsers: The browsers supported by JavaScript Math.E() function are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- JavaScript | Function Parameters
- JavaScript | Function Definitions
- JavaScript | toString( ) function
- JavaScript | Math.pow( ) Function
- JavaScript | Array every() function
- JavaScript | String() Function
- JavaScript | Function Apply
- JavaScript | Function Call
- Javascript | Number() Function
- JavaScript | Array some() function
- JavaScript | toFixed( ) Function
- JavaScript | Array.of() function
- JavaScript | Math.abs( ) function
- JavaScript | Symbol.for() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai



