In this JavaScript tutorial, we are going to learn "Math Object in JavaScript", and much more about Math Object in JavaScript with Examples
What is Math object in JavaScript?
- The Math object in javascript is used to perform mathematical properties in our program.
- Math object in JavaScript is static and it has no constructor.
- It is used to perform mathematical operations in JavaScript such as logarithms, random number generation, and trigonometry.
Math object methods in JavaScript
1. Math.abs()
This JavaScript math object method returns the absolute value of a number
2. Math.round()
This method is used to round a number to the nearest integer.
3. Math.floor()
This method rounds a number down to the nearest integer.
4. Math.ceil()
The Math.ceil() method rounds a number up to the nearest integer.
5. Math.pow()
This method raises a number to a specified power.
6. Math.sqrt()
This JavaScript Math object method returns the square root of a number.
7. Math.random()
This method is used to generate a random number between 0 (inclusive) and 1 (exclusive).
8. Math.cbrt()
This method returns the cube root of the given number.
9. Math.max()
It returns the maximum value of the given numbers.
10. Math.min()
It returns the minimum value of the given numbers.