random

Returns a pseudo-random number between 0 and 1. The random number generator is seeded from the current time, as in Java.

Applies to

Math

Syntax

random()

Parameters

None

Description

random is a static method of Math. As a result, you always use it as Math.random(), rather than as a method of a Math object you create.

Examples

//Returns a random number between 0 and 1
function getRandom() {
      return Math.random()
}