mozilla
Your Search Results

    Math

    Summary

    A built-in object that has properties and methods for mathematical constants and functions.

    Description

    Unlike the other global objects, Math is not a constructor. All properties and methods of Math are static. You refer to the constant pi as Math.PI and you call the sine function as Math.sin(x), where x is the method's argument. Constants are defined with the full precision of real numbers in JavaScript.

    Properties

    E
    Euler's constant and the base of natural logarithms, approximately 2.718.
    LN2
    Natural logarithm of 2, approximately 0.693.
    LN10
    Natural logarithm of 10, approximately 2.303.
    LOG2E
    Base 2 logarithm of E, approximately 1.443.
    LOG10E
    Base 10 logarithm of E, approximately 0.434.
    PI
    Ratio of the circumference of a circle to its diameter, approximately 3.14159.
    SQRT1_2
    Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707.
    SQRT2
    Square root of 2, approximately 1.414.
    Properties inherited from Object:

    Methods

    Note that the trigonometric functions (sin, cos, tan, asin, acos, atan, atan2) expect or return angles in radians - to convert radians to degrees divide by (Math.PI / 180), and multiply by this to convert the other way.
    abs
    Returns the absolute value (modulus) of a number. Note: modulus (%) is also an arithmetic operator.
    acos
    Returns the arccosine of a number.
    asin
    Returns the arcsine of a number.
    atan
    Returns the arctangent of a number.
    atan2
    Returns the arctangent of the quotient of its arguments.
    ceil
    Returns the smallest integer greater than or equal to a number.
    cos
    Returns the cosine of a number.
    exp
    Returns Enumber, where number is the argument, and E is Euler's constant (2.718...), the base of the natural logarithm.
    floor
    Returns the largest integer less than or equal to a number.
    imul
    Returns the result of a 32-bit integer multiplication.
    log
    Returns the natural logarithm (loge, also ln) of a number.
    max
    Returns the largest of zero or more numbers.
    min
    Returns the smallest of zero or more numbers.
    pow
    Returns base to the exponent power, that is, baseexponent.
    random
    Returns a pseudo-random number between 0 and 1.
    round
    Returns the value of a number rounded to the nearest integer.
    sin
    Returns the sine of a number.
    sqrt
    Returns the positive square root of a number.
    tan
    Returns the tangent of a number.
    toSource
    Returns the string "Math".

    Document Tags and Contributors

    Contributors to this page: trucy, teoli
    Last updated by: teoli,