JavaScript Tutorial/Math/Introduction

Материал из Web эксперт
Версия от 08:24, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Advanced mathematical operations are provided through the Math object.

The Math object is a built-in object containing properties and methods used for mathematical computation.

It is a predefined JavaScript object and can be accessed without the use of a constructor or calling method.

All Math properties and methods are static.

Properties and Methods of the Math Object

Property/Method Description abs() Returns absolute value of a number 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 parameters ceil Returns the smallest integer greater than or equal to a number cos() Returns the cosine of a number E Returns the value for Euler"s constant exp() Returns Ex, where x is a number floor() Returns the largest integer less than or equal to a number LN10 Returns the natural logarithm of 10 LN2 Returns the natural logarithm of 2 log() Returns the natural logarithm (base E) of a number LOG10E Returns the base 10 logarithm of E LOG2E Returns the base 2 logarithm of E max() Returns the larger of two arguments min() Returns the smaller of two arguments PI Returns the value of PI pow() Returns base to the exponent power, baseexp random() Returns a random number between 0 and 1 round() Rounds a number to its nearest integer sin() Returns the sine of a number sqrt() Returns the square root of a number SQRT1_2 Returns the square root of ? SQRT2 Returns the square root of 2 tan() Returns the tangent of a number toSource() Creates a copy of an object toString() Returns a string representation of an object



<html>
    <body>
    <title>Example of creating a Math object</title>
    <script language="JavaScript">
    <!--
    
    var newMathObject = Math.E;
    
    document.write(newMathObject);
    
    -->
    </script>
    </body>
    </html>