JavaScript tutorial:
random method

 

Applies to: Math Object

The random method is use to get a pseudorandom number between 0 and 1.

Syntax

Math.random( )

Return value

Returns a pseudorandom number between 0 and 1.

Example

The pseudorandom number generated is between 0 and 1 inclusive. The random number generator is seeded automatically when JavaScript is first loaded.

See also: Math Object Methods