サイト内検索

Math メソッド一覧

スポンサー

ホーム > Math > max

max

最大値を返します.

シンタックス

Math.max(x1, x2, ..., xn)
  • xn - 数値

解説

maxメソッドは引数で指定された数値の最大値を返します.

サンプルコード

以下にmaxメソッドを使用したサンプルコードを示します.

<html>
  <head>
    <title>maxメソッドのサンプルコード</title>
  </head>
  <body>
    <script type="text/javascript" language="javascript">
      document.write(Math.max(1, 2, 3, 4, 5) + "<br />");
      document.write(Math.max(-1, -2, -3, -4, -5) + "<br />");
      document.write(Math.max("1", "2", "3", "4") + "<br />");
      document.write(Math.max("N") + "<br />");
      document.write(Math.max() + "<br />");
    </script>
  </body>
</html>

実行例

サンプルコードの実行結果は以下のようになります.

5
-1
4
NaN
-Infinity

関連項目

スポンサード リンク

inserted by FC2 system