This project is read-only.

max([selector, arg])

Returns the value which its selected value is the maximum.

Syntax

Parameters

selector
Type: function(value, key, arg)
A selector function to each element.
arg
An external argument.
Return Value

The maximum value in the sequence.

Examples

var longs = [ 4294967296, 466855135, 81125 ];

var max = $from(longs).max();

document.writeln("The largest number is " + max);

/*
 This code produces the following output:

 The largest number is 4294967296
*/

var pets = [ { name: "Barley", age: 8 },
             { name: "Boots", age: 4 },
             { name: "Whiskers", age: 1 } ];

var maxPet = $from(pets).max("$age + $name.length");

document.writeln("The pet whose age plus name length is maximum is " + maxPet.name);

/*
 This code produces the following output:

 The pet whose age plus name length is maximum is Barley
*/

Last edited May 17, 2012 at 11:34 AM by suckgamoni, version 3

Comments

No comments yet.