# Math.random() function in javascript

**What is Math?**

**What is Math?**

Before we learn about Math.random() function I would like to tell you that Math is an object in javascript.

The Math object includes several mathematical constants and methods.

Math object allows you to perform mathematical tasks.

Math is not a constructor, hence all properties and methods can be called by using Math as an object without creating it.

Example:

var a = Math.PI; //3.141592653589793 var b = Math.sqrt(25); //5

**Math.random()**

**Math.random()**

The random() method returns a random number from 0 to 1, but not 1.

It is defined in Math object.

Example:

var a = Math.random(); // here the value of a can be anything between 0 and 1 for example 0.6324468343159858

**Click on below topics for step by step understanding.**

How to get random element from Javascript Array and Display it.

Define an array in javascript

array.length in javascript

Math.floor() function in javascript