DEV Community

Raja B
Raja B

Posted on

Math JS

In JavaScript, Math is a built-in object that gives you common math constants

And functions like rounding, square root, power, and random numbers.

It is not a normal object you create with new;

you use it directly like Math.PI or Math.sqrt(25)

Simple idea

  • Math.PI gives the value of pi

  • Math.round(4.6) gives 5

  • Math.floor(4.9) gives 4

  • Math.ceil(4.1) gives 5

  • Math.sqrt(25) gives 5

  • Math.pow(2, 3) gives 8

  • Math.random() gives a random decimal between 0 and 1

Example

math

Reference:

Top comments (0)