The methods of the Math object are: abs(), acos(), asin(), atan(), cos(), floor(), log(), max(), min(), pow( ), random(), round(), sin(), sqrt(), tan(), exp(), etc.
The operating environment of this tutorial: Windows 7 system, ECMAScript version 5, Dell G3 computer.
Math objects are used to perform mathematical tasks.
Methods of Math object
abs(x): Returns the absolute value of the number.
acos(x): Returns the arc cosine of the number.
#asin(x): Returns the arcsine value of the number.
atan(x): Returns the arctangent of x as a value between -PI/2 and PI/2 radians.
atan2(y,x): Returns the angle from the x-axis to the point (x,y) (between -PI/2 and PI/2 radians).
#ceil(x): Round up the logarithm.
cos(x): Returns the cosine of the number.
#exp(x): Returns the exponent of e.
#floor(x): Round down the logarithm.
#log(x): Returns the natural logarithm of the number (base is e).
max(x,y): Returns the highest value between x and y.
min(x,y): Returns the lowest value between x and y.
pow(x,y): Returns x raised to the y power.
random(): Returns a random number between 0 ~ 1.
#round(x): Round the number to the nearest integer.
#sin(x): Returns the sine of the number.
sqrt(x): Returns the square root of the number.
tan(x): Returns the tangent of the angle.
#toSource(): Returns the source code of the object.
#valueOf(): Returns the original value of the Math object.
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of What are the math methods in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!