Math Objects in JavaScript

There are so many operations in mathematics required for many functions in web platforms. Those operations ar in the Math object of JavaScript objects.

The Math object is used to perform simple and complex arithmetic operations.

The main properties and methods of Math Objects are given below.

Properties of Math Object


These are some main properties of Math objects in JavaScript. Now let's learn about the methods in JavaScript. There is a long list of methods for the Math objects; some of them are given below.

Methods of Math Object


That was a little bit about the Math Objects of JavaScript. Now let's do some exercises.

In the following exercise, we are trying to print the value of a given method.



In the preceding code, various mathematical operations are performed using a math object.

  • The Math.floor() method rounds up the number to the nearest smallest number.
  • The Math.log() method finds the logarithmic value of given number.
  • The Math.max() method finds the maximum number from the given list.
  • The Math.min() method finds the minimum number from the given list.
  • The Math.pow(10,2) method finds the value of 10 to the power of 2.
  • The Math.random() method returns a random number between 0 and 1.
  • The Math.round() method rounds up the number to the nearest larger number.
  • The Math.sin() method finds the sin value.
  • The Math.sqrt() method finds out the tangent of a given number.
  • The Math.tan() method finds the Tan value.

So the output for the code above will be:


Up Next
    Ebook Download
    View all
    View all
    Foreantech - A complete online solution company.