The math object in javascript
1 min readJul 15, 2021
Javascript has many built-in objects that are available regardless of window content and operate independently of whatever page your browser has loaded. These objects have different properties and methods that can be used for different purposes.
One of these built-in objects is the math object that is used to…. (surprise!) perform mathematical operations on data.
Some of its main properties are:
- SQRT2 — Returns square root of 2.
- PI — Returns Π value.
- E — Returns Euler’s Constant.
Some of its main methods are:
- ceil()It returns a smallest integer value, greater than or equal to the given number.
- cos()It returns the cosine of the given number.cosh()It returns the hyperbolic cosine of the given number.
- exp()It returns the exponential form of the given number.
- floor()It returns largest integer value, lower than or equal to the given number.
- log()It returns natural logarithm of a number.
- max()It returns maximum value of the given numbers.
- min()It returns minimum value of the given numbers.
- pow()It returns value of base to the power of exponent.
- random()It returns random number between 0 (inclusive) and 1 (exclusive).
- round()It returns closest integer value of the given number.
- trunc()It returns an integer part of the given number.