最小値を返します.
Math.min(x1, x2, ..., xn)
minメソッドは引数で指定された数値の最小値を返します.
以下にminメソッドを使用したサンプルコードを示します.
<html>
<head>
<title>minメソッドのサンプルコード</title>
</head>
<body>
<script type="text/javascript" language="javascript">
document.write(Math.min(1, 2, 3, 4, 5) + "<br />");
document.write(Math.min(-1, -2, -3, -4, -5) + "<br />");
document.write(Math.min("1", "2", "3", "4") + "<br />");
document.write(Math.min("N") + "<br />");
document.write(Math.min() + "<br />");
</script>
</body>
</html>
サンプルコードの実行結果は以下のようになります.
1 -5 1 NaN Infinity
スポンサード リンク