JavaScript Math Object

The JavaScript Math object provides several methods to perform mathematical operations on numbers. But unlike other global objects, Math is not a constructor. All the properties and methods of Math are static and can be called by using Math as an object without creating it. The syntax would be :
  var x = Math.method();
Example :
  var x = 12.54;
  var y = Math.floor(x);
Output :

JavaScript Math object Methods :

  • abs() : Returns the absolute value of a number. Example :
  • acos() : Returns the arccosine of a number, in radians. Example
  • asin() : Returns the arcsine of a number, in radians. Example :
  • atan() : Returns the arctangent of a numeric value, in radians. Example :
  • atan2(y, x) : Returns the arctangent of the quotient of its arguments. Example
  • ceil() : Returns the smallest integer greater than or equal to a number. Example
  • cos() : Returns the cosine of a number, in radians. Example
  • exp() : Returns the value of E^N, where N is the argument and E is Euler's constant, the base of the natural logarithm.
  • floor() : Returns the value of given number rounded down to its nearest integer.
  • log() : Returns the natural logarithm (base E) of given number.
  • max() : Returns the number with the highest value.
  • min() : Returns the number with the lowest value.
  • pow(x, y) : Returns the value of x to the power of y.
  • random() : Returns a random number between 0 and 1.
  • round() : Returns the value of given number, rounded to its nearest integer.
  • sin() : Returns the sine of given number, in radians.
  • sqrt() : Returns the square root of given number.
  • tan() : Returns the tangent of an angle.

Next Topic :