Learn JavaScript Math Object, Free JavaScript Tutorial for Beginners, Interactive JavaScript Examples

# javascript math function examples

In JavaScript, Math is a global object with many in-built static properties and methods.

## How to use JavaScript built-in Math Methods

Here are few static properties of JavaScript Math Object like `Math.PI`, this Math property will return the Pie Value

```
document.write(" Math.PI : returns " + Math.PI);
document.write("<br>");
document.write(" Math.E : returns " + Math.E);
document.write("<br>");
document.write(" Math.SQRT2 : returns " + Math.SQRT2);
document.write("<br>");
document.write(" Math.LN2 : returns " + Math.LN2);
document.write("<br>");

```

In this tutorial you will learn JavaScript Math Functions, that will allow you to perform many mathematical tasks on numbers.

1. ### Math.round() in Javascript

Math.round(x) returns the rounded value of x , here is an example

2. Math.ceil(), Math.floor() in Javascript
Math.ceil(x) returns the rounded up to its nearest integer AND Math.floor(x) rounded down to its nearest integer:

3. Math.pow() in Javascript
Math.pow(x, y) returns the value of x to the power of y

4. Math.sqrt() in Javascript
Math.sqrt(x) returns the square root value of x:

5. Math.random()

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

If you keep on refreshing this page the random number will also keep on changing on this page, try refresh

6. Math.max() and Math.min()

Math.max() and Math.max() is used to find the lowest or highest value of any given arguments, let's look at the example below.

7. Math.abs()

Math.abs(x) returns an absolute positive value of a number:

8. Math.cos()

Math.cos(x) returns an Cosine value of a number:

9. Math.tan()

Math.tan(x) returns the Tangent value of a number:

10. Math.sin()

Math.sin(x) returns the Sine value of a number:

11. Math.log()

Math.log(x) returns the logarithmic value of a number:

Comment
Name
Email
Website
Subscribe

JavaScript Math Function

JavaScript Examples |