Math.exp(x) returns Euler's number e raised to the power x. In mathematical notation, it calculates ex.
console.log(Math.exp(1)); // 2.718281828459045
console.log(Math.exp(2)); // 7.38905609893065Math.exp(x)console.log(Math.exp(2)); // 7.38905609893065
console.log(Math.exp(0.25)); // 1.2840254166877414console.log(Math.exp(-2)); // 0.1353352832366127
console.log(Math.exp(-0.46)); // about 0.6312836455console.log(Math.exp(0)); // 1console.log(Math.exp(3));
console.log(Math.pow(Math.E, 3));
console.log(Math.E ** 3);All three express the same mathematical idea, though floating-point representation may affect the last digits.
const x = 2.5;
console.log(Math.log(Math.exp(x))); // approximately 2.5
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.