Here you can find the source of min()
//minNum()//from w w w . j a v a 2s .c om //Write a function minNum() that accepts an array of numbers and //returns the minimum number in the array maxNum([1,2,3]); //1 maxNum([10,3,10,4]); //3 maxNum([-5,100]); //-5 //Solution function minNum(arr) { var len = arr.length; var min = Infinity; while (len--) { if (arr[len] < min) { min = arr[len]; } } return min; } //other method var arr = [1,3,5]; Array.prototype.min = function() { return Math.min.apply(null, this); } console.log(arr.min());
Array.prototype.min = function () { "use strict"; return Math.min.apply(null, this); };
Array.prototype.min = function() { return Math.min.apply(Math, this); };
function Calculator(array){ var self = this; (function(array){ self.min = array.min(); self.max = array.max(); self.avg = array.avg(); })(array); Array.prototype.min = function(){ ...
Array.prototype.min = function() { var r = null; for (var i = 0; i < this.length; i++) { if (r === null || this[i] < r) { r = this[i]; return r; }; ...
Array.prototype.min = function(){ var min=this[0]; this.forEach(function(v){min=(v<min)?v:min;}); return min; };
Array.prototype.min = function() { var min = this[0]; var len = this.length; for (var i = 1; i < len; i++){ if (this[i] < min){ min = this[i]; return min; ...
Array.prototype.min = function() { return this.reduce(function(p, v) { return (p < v ? p : v); });
Array.prototype.min = function() { return Math.min.apply(null, this); }; Array.prototype.diff = function(a) { return this.filter(function(i) {return i!=a;}); };
Array.prototype.min = function(){ var i, min = this[0]; for (i = 1; i < this.length; i++){ if (min > this[i]) min = this[i]; return min; };