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>

出力