max :: Enumerable

max([iterator = Prototype.K]) -> maxValue Returns the maximum element (or element-based computation), or undefined if the enumeration is empty. Elements are either compared directly, or by first applying the iterator and comparing returned values.

Note: for equivalent elements, the latest one is returned.

Examples

$R(1,10).max()

// -> 10

['hello', 'world', 'gizmo'].max()

// -> 'world'

function Person(name, age) {

this.name = name;

this.age = age;

}

var john = new Person('John', 20);

var mark = new Person('Mark', 35);

var daisy = new Person('Daisy', 22);

[john, mark, daisy].max(function(person) {

return person.age;

})

// -> 35

Prototype API 1.5.0 - prototypejs.org