JavaScript Math

You may use the JavaScript Math object to execute mathematical operations. The following is a list of JavaScript Math methods, along with their descriptions.

abs()Returns the absolute valueMath.abs(-9)9
acos()Returns the arccosine valueMath.acos(-1)3.141592653589793
asin()Returns the arcsine valueMath.asin(-1)-1.5707963267948966
ceil()Returns a smallest integerMath.ceil(1.2)2
ceil()Returns a largest integerMath.floor(1.2)1
max()Returns the highest value from a given number.Math.max(5,-2,3,-7)5
min()Returns the least value from a given number.Math.max(5,-2,3,-7)-7
sqrt()Returns the square root of a given value.Math.sqrt(64)8
round()Number rounded to the nearest integerMath.round( 10.3 )10

Lets take an example of Math.random() method. This function returns a random number.

console.log(Math.random()); // 0.3938153920684837
console.log(Math.random()); // 0.41823122735824025
console.log(Math.random()); // 0.6175441817050966