javascript手冊-m&n[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 longj 的 blog

 

math object

a built-in object that has properties and methods for mathematical constants and functions. for example, the math object's pi property has the value of pi.

语法

to use a math object:

1. math.propertyname
2. math.methodname(parameters)
propertyname is one of the properties listed below.
methodname is one of the methods listed below.

property of

  • none.

    description

    the math object is a built-in javascript object.

    you reference the constant pi as math.pi. constants are defined with the full precision of real numbers in javascript.

    similarly, you reference math functions as methods. for example, the sine function is math.sin(argument), where argument is the argument.

    it is often convenient to use the with statement when a section of code uses several math constants and methods, so you don't have to type "math" repeatedly. for example,

    with (math) {
       a = pi * r*r
       y = r*sin(theta)
       x = r*cos(theta)
    }
    

    properties

  • e
  • ln2
  • ln10
  • log2e
  • log10e
  • pi
  • sqrt1_2
  • sqrt2

    methods

  • abs
  • acos
  • asin
  • atan
  • ceil
  • cos
  • exp
  • floor
  • log
  • max
  • min
  • pow
  • random
  • 本文关键:javascript
     

    本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

    go top