Javascript Array min(prop)

Description

Javascript Array min(prop)


Array.prototype.min = function (prop) {
    var min = prop ? this[0][prop] : this[0];
    var len = this.length;
    for (var i = 1; i < len; i++) {
        var item = prop ? this[i][prop] : this[i];
        if (item < min) {
            min = item;//from   w  w  w .  ja  va2  s  .co m
        }
    }
    return min;
};



PreviousNext

Related