The Math.exp() function in JavaScript is used to return ex, where x is the argument, and e is Euler’s number, which is the base of the natural logarithms.
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 Used:
Value:A number whose ex you want to find.
Return Value:
The Math.exp() function returns ex where e is Euler’s number and x is the argument.
Examples:
- When zero is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.exp(0));
</
script
>
Output:
Output : 1
- When “-1” is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.exp(-1));
</
script
>
Output:
Output : 0.36787944117144233
- When “1” is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.exp(1));
</
script
>
Output:
Output : 2.718281828459045
leave a comment
0 Comments