The Math.expm1()
function returns ex - 1
, where x
is the argument, and e the base of the natural logarithms.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
Math.expm1(x)
Parameters
x
- Um número.
Return value
Um número representando ex - 1
, onde e
é Euler's number e x
ié o argumento.
Description
Porque expm1()
é um método estático de is Math
, você sempre o usurá como Math.expm1()
, do que como um método de um objeto Math
que você criou (Math
não é um contrutor).
Polyfill
This can be emulated with the help of the Math.exp()
function:
Math.expm1 = Math.expm1 || function(x) {
return Math.exp(x) - 1;
};
Examples
Using Math.expm1()
Math.expm1(-1); // -0.6321205588285577
Math.expm1(0); // 0
Math.expm1(1); // 1.718281828459045
Specifications
Browser compatibility
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.