ee.List.get

Returns the element at the specified position in list. A negative index counts backwards from the end of the list.

UsageReturns
List.get(index)Object
ArgumentTypeDetails
this: listList

indexInteger

Examples

Code Editor (JavaScript)

// An ee.List object.
var list = ee.List([5, 10, 15, 20, 25, 30]);

// Fetch elements at specified 0-based positions in the list.
print('The second element', list.get(1));
print('The fourth element', list.get(3));
print('The last element', list.get(-1));
print('The second to last element', list.get(-2));

// ee.Number and integer computed objects are valid inputs.
print('Computed object index input', list.get(list.get(0)));

// The result of ee.List.get is an ambiguous object type. You need to cast the
// result to the expected type to use it in subsequent instance methods. For
// example, if you are fetching a number and wish to add it to another number,
// you must cast the .get() result as an ee.Number.
print('Add fetched number to another number', ee.Number(list.get(1)).add(2));