Math Object in JavaScript
The Math Object
The Math object allows you to perform mathematical tasks and includes several properties. Math has no constructor. There's no need to create a Math object first.
Math object contains following properties and methods:-
Method | Description |
abs(x) | Return absolute value |
acos(x) | Return the arccosine of x in radian |
asin(x) | Return the arcsin of x in radian |
atan(x) | Return the arctangent of x as numeric value |
ceil(x) | Return x, rounded upwards to near integer |
floor(x) | Return x, rounded downwards to near integer |
log(x) | Return the natural logarithm of x |
pow(x,t) | Return the value of x to the power t |
random() | Return random between 0 and 1 |
round(x) | Return to nearest integer |
sinx(x) | Return the sine of x |
tanx(x) | Return the tan of x |
sqrt(x) | Return the square root of x |
max() and min() | Return maximum and minimum values respectively |