The `Math.random()` function generates and returns a pseudo-random value; a positive value between 0 and 1.

The resulting value is chosen randomly (or pseudo randomly) depending on the implementation.

In any case, regardless of how it is selected, it should yield a uniform distribution over the range of possible values.

The exact value yielded by this function may vary slightly from implementation to implementation due to differences in the underlying precision of the implementations math routines, and the specific algorithm selected to generate the random numbers.

Some implementations may provide a way to seed the random number sequence although the ECMAScript standard does not describe this capability.

Some implementations provide predictable series of random numbers that always start at the same seed point.

The algorithm and strategy is implementation dependant and the standard offers no recommendations as to which is best.

Although this is noted as being available in Netscape 2.02, that only applies to the Unix platform. It wasn't widely available until JavaScript 1.1 was supported in Netscape 3.0 on the remaining platforms.

See also: | Math object, Pseudo-random numbers |

Prev | Home | Next |

Math.pow() | Up | Math.round() |

JavaScript Programmer's Reference, Cliff WoottonWrox Press (www.wrox.com)Join the Wrox JavaScript forum at p2p.wrox.comPlease report problems to support@wrox.com© 2001 Wrox Press. All Rights Reserved. Terms and conditions. |