Methods available in Math Object for basic calculation in javascript?
Constant | Example Code | Result | Description |
abs(value) | Math.abs(2.822); | abs() method returns the absolute value of the argument passed. | |
ceil(value) | Math.ceil(3.44); | ceil() method returns the nearest greater integer value of the value passed as argument. The argument can be an integer or float. | |
floor(value) | Math.floor(2.44); | floor() method returns the nearest lowest (least) integer value of the argument passed. | |
log(value) | Math.log(3); | - | Result: log(x) function returns the natural logarithm of the value used. |
max(value1, value2) | Math.max(14, 12); | Math.max(value1, value2) compares the two values and returns the maximum value of the two values passed. | |
min(value1, value2) | Math.min(14, 12); | Math.min(value1, value2) compares the two values and returns the minimum value of the two values passed. | |
pow(value1, value2) | Math.pow(4, 2); | Math.pow(value1, value2) function is used to calculate xy calculation. Here it is 42. | |
random() | Math.random() | Math.random() gives a random value between 0 and 1. more... | |
round() | Math.round(9.678); | Math.round() function is used to round a float (decimal) value to the nearest integer value. i.e. round of 4.5 will give 5, rounding of 4.4 will give 4. |