javascript random method is used to return a random number between 0 and 1. Its usage syntax is such as "Math.random()", and the return value is a pseudo-random number between 0.0 and 1.0. .
The operating environment of this article: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.
How to use javascript random method?
JavaScript random() method
Definition and usage
random() method can return a value between 0 ~ 1 random number.
Syntax
Math.random()
Return value
A pseudo-random number between 0.0 ~ 1.0.
Example
In this example, we will get a random number between 0 and 1:
<script type="text/javascript"> document.write(Math.random()) </script>
Output:
0.8187371959444101
Recommended Study: "javascript basic tutorial"
The above is the detailed content of How to use javascript random method. For more information, please follow other related articles on the PHP Chinese website!