Math.exp()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Die statische Methode Math.exp() gibt e potenziert mit einer gegebenen Zahl zurück. Das heißt:

𝙼𝚊𝚝𝚑.𝚎𝚡𝚙(𝚡)=ex\mathtt{\operatorname{Math.exp}(x)}} = \mathrm{e}^x

Probieren Sie es aus

console.log(Math.exp(0));
// Expected output: 1

console.log(Math.exp(1));
// Expected output: 2.718281828459 (approximately)

console.log(Math.exp(-1));
// Expected output: 0.36787944117144233

console.log(Math.exp(2));
// Expected output: 7.38905609893065

Syntax

js
Math.exp(x)

Parameter

x

Eine Zahl.

Rückgabewert

Eine nicht-negative Zahl, die ex repräsentiert, wobei e die Basis des natürlichen Logarithmus ist.

Beschreibung

Da exp() eine statische Methode von Math ist, verwenden Sie sie immer als Math.exp() und nicht als Methode eines von Ihnen erstellten Math-Objekts (Math ist kein Konstruktor).

Beachten Sie, dass e potenziert mit einer Zahl, die sehr nah an 0 liegt, nahe bei 1 liegt und unter Präzisionsverlust leiden kann. In diesem Fall sollten Sie stattdessen Math.expm1 verwenden, um eine präzisere Nachkommastelle des Ergebnisses zu erhalten.

Beispiele

Verwendung von Math.exp()

js
Math.exp(-Infinity); // 0
Math.exp(-1); // 0.36787944117144233
Math.exp(0); // 1
Math.exp(1); // 2.718281828459045
Math.exp(Infinity); // Infinity

Spezifikationen

Specification
ECMAScript® 2025 Language Specification
# sec-math.exp

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
exp

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Siehe auch