To make mathematical calculation easier on numbers, javascript provides Math object. Its all properties and methods are static means it can be directly used without creating its object.
Math only works with numbers not with BigInt data type.
Math object Properties
Math Properties | Description | Approximate values |
Math.E | Gives Euler’s number | 2.718 |
Math.LN10 | Gives Natural logarithm of 10 | 2.303 |
Math.LN2 | Gives Natural logarithm of 2 | 0.693 |
Math.PI | 3.14159 | |
Math.LOG10E | Gives Base-10 logarithm of E | 0.434 |
Math.LOG2E | Gives Base-2 logarithm of E | 1.443 |
Math Static methods
Math methods | Use |
Math.sqrt() | Gives Square root |
Math.round() | Gives rounded value |
Math.random() | Gives random number between 0 to 1. |
Math.pow() | Gives power of given number raises to the second number |
Math.ceil() | |
Math.abs() | Gives Absolute number |