at(index)

suckgamoni edited this page May 14, 2013 · 1 revision

Returns the element at a specified index in a sequence.

Syntax

Parameters

index

Type: number
The zero-based index of the element to retrieve.

Return Value

The element at the specified position in the source sequence.


Example

var names = [ "Hartono, Tommy", "Adams, Terry", "Andersen, Henriette Thaulow",  "Hedlund, Magnus", "Ito, Shu" ];

var name = from(names).at(parseInt(Math.random() * names.length));

console.log("The name chosen at random is '" + name + "'.");

/*
This code produces the following sample output:

The name chosen at random is 'Ito, Shu'.
*/