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
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)
}