Function | Description | Example | |
---|---|---|---|
abs(x) | Returns the absolute value of a number. | Math.abs(-10) | //Returns 10 |
acos(x) | Returns the arccosine of a number. | Math.acos(1) | //Returns 0 |
asin(x) | Returns the arcsine of a number. | Math.asin(1) | //Returns 1.5707963267948965 |
atan(x) | Returns the arctangent of a number, which is between -PI/2 and PI/2 radians. | Math.atan(0.50) | //Returns 0.4636476090008061 |
atan2(y, x) | Returns the angle in radians between the X axis and the point (x, y), which is between -PI/2 and PI/2 radians. | Math.atan2(5, 5) | //Outputs 0.7853981633974483 |
ceil(x) | Rounds a number up to the nearest integer. | Math.ceil(0.60) |
//Returns 1 //Returns -5 |
cos(x) | Returns the cosine of a number. | Math.cos(0) | //Returns 1 |
exp(x) | Returns e to the power of a number. | Math.exp(5) | //Returns 148.4131591025766 |
floor(x) | Rounds a number down to the nearest integer. | Math.floor(0.60) Math.floor(-5.1) |
//Returns 0 //Returns -6 |
log(x) | Returns the natural logarithm of a number (base e). | Math.log(1) | //Returns 0 |
max(x,y) | Returns the maximum value between x and y. | Math.max(5,7) | //Returns 7 |
min(x,y) | Returns the minimum value between x and y. | Math.min(5,7) | //Returns 5 |
pow(x,y) | Returns the value of x raised to the power of y. | Math.pow(2,4) | //Returns 16 |
random() | Returns a random number between and 1. | Math.random() | //Returns a random number such as 0.6654807284142312 |
round(x) | Rounds a number to the nearest integer. | Math.round(0.60) Math.round(-4.4) |
//Returns 1 //Returns -4 |
sin(x) | Returns the sine of a number. | Math.sin(0) | //Returns 0 |
sqrt(x) | Returns the square root of a number. | Math.sqrt(0.64) | //Returns 0.8 |
tan(x) | Returns the tangent of an angle. | Math.tan(10) | //Returns 0.648360827459866 |