Javascript Math object also provides some properties along with Math functions. Javascript Math object properties return the constant values for Math constants such as Pi or Euler’s constant. Math object properties return pre calculated values also e.g.: natural Log value of 2 or 10. Following are the Javascript Math object properties:
Math.E: returns the value of Euler’s constant. (2.718281828459045)
Math.LN10: returns the natural log of 10. (2.302585092994046)
Math.LN2: returns the natural log of 2. (0.6931471805599453)
Math.LOG10E: returns the base-10 log of E. (0.4342944819032518)
Math.LOG2E: returns the base-2 log of E. (1.4426950408889633)
Math.PI: returns the constant value of PI. (22/7 = 3.141592653589793)
Math.SQRT1_2: returns the value of square root of ½. (0.7071067811865476)
Math.SQRT2: returns the square root of 2. (1.4142135623730951)
Above Javascript Math properties return the predefined values for the constants like Pi and E. Other properties like LOG10E, LN10, SQRT2 provides the pre calculated values that reduces the code length by eliminating the logical code for deriving the values each time when they are required. You can directly use these Javascript Math object properties.
Click here to learn Javascript Math Functions.
Be the first to rate this post
Tags: javascript, javascript math object, javascript math properties, javascript math functions, javascript math.abs, javascript math.ceil, javascript math.floor, javascript math.pow, javascript math.round, javascript math.random, javascript math.log, javascript math.sqrt
10/11/2008 3:21:19 AM