random function:
Returns a pseudo-random number between 0 and 1. The random number generator is seeded from the current time, as in Java.
Syntax:
random()
Description:
Because random is a static method of Math, you always use it as Math.random(), rather than as a method of a Math object you created.
Example in HEAD section:
| <html> <head> <title>Random Function</title> <script language="javascript"> document.write(Math.random(1)); </script> </head> </html> |
Example in BODY section:
| <html> <head> <title>Random Function</title> </head> <body> <script language="javascript"> document.write(Math.random(1)); </script> </body> </html> |
OUTPUT
0.7415897142562586