November 5, 1999 - Mathematical Constants | WebReference

November 5, 1999 - Mathematical Constants

Yehuda Shiran November 5, 1999
Mathematical Constants
Tips: November 1999

Yehuda Shiran, Ph.D.
Doc JavaScript

JavaScript's built-in Math object provides various mathematics functionality and constants. It is a top-level, predefined JavaScript object, so it cannot be instantiated using the new operator. The properties of this object are well known mathematical constants:

PropertyDescription
Math.EReturns Euler's constant, the base of natural logarithms. The E property is approximately equal to 2.718.
Math.LN10Returns the natural logarithm of 10. The LN10 property is approximately equal to 2.302.
Math.LN2Returns the natural logarithm of 2. The LN2 property is approximately equal to 0.693.
Math.LOG10EReturns the base-10 logarithm of E, Euler's constant. The LOG10E property is approximately equal to 0.434.
Math.2EReturns the base-2 logarithm of E, Euler's constant. The LOG2E property is approximately equal to 1.442.
Math.PIReturns the ratio of the circumference of a circle to its diameter. The PI property is approximately equal to 3.14159.
Math.SQRT1_2Returns he square root of 0.5, or one divided by the square root of 2. The SQRT1_2 property is approximately equal to 0.707.
Math.SQRT2Returns the square root of 2. The SQRT2 property is approximately equal to 1.414.

The following function returns the area of a circle with a given radius:

function circle(r) {
  return Math.PI * r * r;
}