# The most common JavaScript Math Functions

What is a Math function in JavaScript?

Well, first of all, it is not a function. According to MDN documentation, Math is is a built-in object that has properties and methods for mathematical constants and functions. It works with the Number data type and allows you to perform a vast range of mathematical tasks.

In this blog, I’ll make a top 8 of the most common and useful Math functions.

1.Math.round(x) — returns the value of x rounded to its nearest integer:

Math.round(7.7); // returns 8
Math.round(7.3); // returns 7

2. Math.pow(x, y) returns the value of x to the power of y:

Math.pow(8, 2); // returns 64

3. Math.sqrt(x) returns the square root of x:

Math.sqrt(49); // returns 7

4. Math.abc(x) returns the absolute value of x:

Math.abs(-2); // returns 2

5. Math.ceil(x) returns the value of x rounded up to its nearest integer:

Math.ceil(3.4); // returns 4

6. Math.floor(x) returns the value of x rounded down to its nearest integer:

Math.floor(3.4); // returns 3

7. Math.min() and Math.max() are used to find the lowest or highest value in a list of arguments

Math.min(0, 150, 30, 20, -8, -200); // returns -200

8. Math.random() returns a random number between 0 (inclusive), and 1 (exclusive):

Math.random(); // returns a random number

Source:

--

--