min() 要素の最小値を取得する
<script>
Array.prototype._each = function(iterator){
for(var i=0, l=this.length; i<l; i++){
iterator(this[i]);
}
};
Array.prototype.each = function(iterator){
var index = 0;
try{
this._each(function(v){
iterator(v, index++);
});
} catch(e){
if(e != $break) throw e;
}
};
Array.prototype.min = function(iterator){
var iterator = iterator || function(x){return x};
var rs;
this.each(function(v, k){
v = iterator(v, k);
if(rs == undefined || v < rs)
rs = v;
});
return rs;
};
var kekka = [1,2,3,4,5,4,12,3,2].min();
console.log(kekka);
</script>