Math Object - Javascript

  • let var = MATH
  • Math.PI => Gives the value of pi
  • Math.E => Gives eulers number
  • Math.LN2
  • Math.LOG2E
  • Math.SQRT1_2
  • Math.round(n) => Round off number
  • Math.pow(n1, n2) => n1 raised to power n2
  • Math.sqrt(n) => Square root of number
  • Math.ceil(n) => Returns ceiling value of n
  • Math.floor(n) => Returns floor value of n
  • Math.abs(n) => Returns exact value as n, Converts -ve into +ve
  • Math.sin(radian)
  • Math.cos(radian)
  • Math.tan(radian)
  • Math.max(n1,n2,n3)
  • Math.min(n1,n2,n3) => Returns minimum & maximum value
  • Math.random() => Generated random number from 0 to 1
    • To get numbers from a to b => a + (b-a)*Math.random()
Share: