Javascript-math-random
提供:Dev Guides
JavaScript-数学ランダムメソッド
説明
このメソッドは、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>