要素内の最小値を返す

書式

enumObj.min(iterator)

enumObj : 列挙型オブジェクト
iterator : イテレータ関数【省略可能】

説明

要素内にある値の最小値を返すにはmin()を使います。パラメータを指定しない場合は単純に最小値を返します。パラメータに処理(イテレータ)関数を指定した場合は、関数からの戻り値と比較し最小値を返します。

サンプルコード [実行]

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="main.css" type="text/css" media="all">
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript"><!--
window.onload = function() {
$("result").innerHTML = [1,2,4,10,5,3].min() +"<br>";
$("result").innerHTML += [1,2,4,10,5,3].min(function(value, index){
return -value;
});
}
// --></script>
</head>
<body>
<h1>minサンプル</h1>
<div id="result"></div>
</body>
</html>