The math object, which provides a mathematical calculation of the data.
Note: The Math object is an intrinsic object that you can call all of its properties and methods without having to create it, directly using math as an object. This is what distinguishes it from objects such as Date, String, and so on.
Common methods:
1: Rounding up
The Math.ceil (num) method can be rounded up to a number, which is 1 as long as there is a decimal.
Example:
Math.ceil (1.5123); Returns 2
Math.ceil (1.4123); Also returns 2
Math.ceil (1.000000001); Also returns 2
2: Rounding Down
The Math.floor (num) method can be rounded down one number, or the fractional part is discarded.
Example:
Math.floor (1.4123); Returns 1
Math.floor (1.5123); Also returns 1
Math.floor (1.000000001); Also returns 1
3: Rounding
The Math.Round (num) method rounds a number to the nearest integer.
Example:
Math.Round (1.4123); Returns 1
Math.Round (1.5123); Returns 2
4: Random number
The Math.random () method returns a random number between 0-1 (greater than or equal to 0 but less than 1).
Js-math Object