Javascript Math.random()方法
作者:--
发布时间:2019-11-20
评论:0
阅读:2
此方法返回0(含)和1(不包括)之间的随机数
语法
math.random() ;
下面是参数的详细信息:
返回值:
返回0(含)和1(不包括)之间的随机数
例子:
<html>
<head>
<title>javascript math random() method</title>
</head>
<body>
<script type="text/javascript">
var value = math.random( );
document.write("first test value : " + value );
var value = math.random( );
document.write("<br />second test value : " + value );
var value = math.random( );
document.write("<br />third test value : " + value );
var value = math.random( );
document.write("<br />fourth test value : " + value );
</script>
</body>
</html>
这将产生以下结果:
first test value : 0.28182050319352636
second test value : 0.6375786089661319
third test value : 0.6780129774072902
fourth test value : 0.7310958163154001