Math object's properties and methods

The Math object's properties and methods are described below:

NN: Netscape, IE: Internet Explorer

Properties

Syntax: object.property_name

PropertyDescriptionNNIE 
EReturns the base of a natural logarithm23
LN2Returns the natural logarithm of 223
LN10Returns the natural logarithm of 1023
LOG2EReturns the base-2 logarithm of E23
LOG10EReturns the base-10 logarithm of E23
PIReturns PI23
SQRT1_2Returns 1 divided by the square root of 223
SQRT2Returns the square root of 223

Methods

Syntax: object.method_name()

MethodDescriptionNNIE
abs(x)Returns the absolute value of x23
acos(x)Returns the arccosine of x23
asin(x)Returns the arcsine of x23
atan(x)Returns the arctangent of x23
atan2(y,x)Returns the angle from the x axis to a point23
ceil(x)Returns the nearest integer greater than or equal to x23
cos(x)Returns the cosine of x23
exp(x)Returns the value of E raised to the power of x23
floor(x)Returns the nearest integer less than or equal to x23
log(x)Returns the natural log of x23
max(x,y)Returns the number with the highest value of x and y23
min(x,y)Returns the number with the lowest value of x and y23
pow(x,y)Returns the value of the number x raised to the power of y23
random()Returns a random number between 0 and 123
round(x)Rounds x to the nearest integer23
sin(x)Returns the sine of x23
sqrt(x)Returns the square root of x23
tan(x)Returns the tangent of x23
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章