JavaScript Math Constants

JavaScript exposes common mathematical constants as read-only properties of the built-in Math object. The most frequently used is Math.PI.

const radius = 2;
const circumference = 2 * Math.PI * radius;
console.log(circumference); // 12.566370614359172

JavaScript Math constants Top ↑

ConstantMeaning
Math.PIRatio of a circle's circumference to its diameter.
Math.EEuler's number, the base of natural logarithms.
Math.LN2Natural logarithm of 2.
Math.LN10Natural logarithm of 10.
Math.LOG2EBase-2 logarithm of e.
Math.LOG10EBase-10 logarithm of e.
Math.SQRT2Square root of 2.
Math.SQRT1_2Square root of 1/2.

Using Math.PI Top ↑

const radius = 5;
const area = Math.PI * radius ** 2;
console.log(area);

Using Math.E Top ↑

console.log(Math.E);
console.log(Math.exp(1)); // same mathematical value as e, subject to Number precision

Logarithm constants Top ↑

Math.LN2 and Math.LN10 are useful when natural logarithms are involved. For direct logarithm calculations, see Math.log().

console.log(Math.LN2);
console.log(Math.log(2));

Square-root constants Top ↑

Math.SQRT2 and Math.SQRT1_2 provide commonly used square-root values. For arbitrary inputs, use Math.sqrt().

Precision and comparisons Top ↑

The displayed decimal values are approximations stored as JavaScript Number values. Avoid comparing long decimal results by typing a rounded decimal literal when a tolerance comparison is more appropriate.

Math.log()




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer