JavaScript Math.exp() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Math

Definition

Math.exp(x) returns e to the power of x. Here e is Euler's number, about 2.71828. It is the same as Math.E ** x.

Math is built into JavaScript. Call the method directly. It is not a constructor, so never write new Math().

Syntax

Call Math.exp() like this. Start with this line.

JavaScript
Math.exp(x)
CallWhat it does
Math.exp(x)Returns e raised to the power x.

Built into JavaScript. Call Math.exp() on the Math object — no import required.

Library declarations
JavaScript
Math.exp(x)
JavaScript
interface Math {
  exp(x: number): number;
}

Parameters

ParameterDescription
xRequired. A number. Other values are converted to a number first.

Return Value

Return ValueDescription
numbere raised to the power x. Returns NaN if x cannot be turned into a number.

JavaScript Examples

Example 1 — Basic Use

Pass the power. You get e raised to it.

JavaScript
console.log(Math.exp(0));    // 1
console.log(Math.exp(1));    // 2.718281828459045
console.log(Math.exp(2));    // 7.38905609893065
console.log(Math.exp(-1));   // 0.36787944117144233
Try It Yourself

How It Works

  1. Power 0. Anything to the power 0 is 1.
  2. Power 1. Math.exp(1) is e itself, about 2.718.
  3. Negative power. Math.exp(-1) is 1 / e, about 0.368.

Example 2 — Continuous Compound Growth

With continuous growth, money grows by P * e^(rate * time).

JavaScript
var principal = 1000;
var rate = 0.05;   // 5% per year
var years = 3;

var total = principal * Math.exp(rate * years);
console.log(total.toFixed(2));  // 1161.83
Try It Yourself

How It Works

  1. Set values. Start with 1000, a 5% rate, and 3 years.
  2. Multiply rate and time. rate * years is 0.15.
  3. Apply exp. Math.exp(0.15) is about 1.1618, so the total is about 1161.83.

Example 3 — Opposite of log() and Limits

exp and log undo each other. Huge and tiny inputs hit the limits of a number.

JavaScript
console.log(Math.log(Math.exp(3)));            // 3
console.log(Math.exp(Math.log(10)).toFixed(4)); // 10.0000

console.log(Math.exp(710));    // Infinity
console.log(Math.exp(-1000));  // 0
Try It Yourself

How It Works

  1. Undo with log. Math.log(Math.exp(3)) gives back 3.
  2. Undo with exp. Math.exp(Math.log(10)) gives 10 (round to hide tiny noise).
  3. Too big. Math.exp(710) is Infinity.
  4. Too small. Math.exp(-1000) rounds down to 0.

Browser & Runtime Support

Math.exp() has been part of JavaScript since ES1 and is Baseline Widely available everywhere.

✓ Baseline · ES1

Math.exp()

Supported in every browser and Node.js version. No polyfill is needed.

99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Math.exp Excellent

Bottom line: Use Math.exp() freely. It works in all browsers and runtimes.

Frequently Asked Questions

Math.exp(x) returns e raised to the power x. Math.exp(0) is 1 and Math.exp(1) is about 2.718281828459045.
e is Euler's number, about 2.71828. You can read it from Math.E.
They are opposites. Math.log(Math.exp(x)) gives back x.
It returns Infinity, because the result is too big for a JavaScript number.
Math.exp(x) always uses base e. Math.pow(base, x) lets you choose the base.

Next: expm1()

Learn how to calculate e to a power minus 1 accurately.

expm1() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful