take(count)

Returns a specified number of contiguous elements from the start of a sequence.

Syntax

Parameters

count
Type: number
The number of elements to return.
Return Value

An iteratable object that contains the specified number of elements from the start of the input sequence.

Examples

var grades = [ 59, 82, 70, 56, 92, 98, 85 ];

var topThreeGrades = $from(grades).orderByDesc("$").take(3);

document.writeln("The top three grades are:");
topThreeGrades.each("document.writeln($)");
/*
 This code produces the following output:

 The top three grades are:
 98
 92
 85
*/

Last edited May 18, 2012 at 10:50 AM by suckgamoni, version 1

Comments

No comments yet.