Lists

It is helpful to store multiple values in a single variable. JavaScript provides a data structure called a list that can hold multiple values. We can create a new list using the square brackets [ ] and add multiple values separated by a comma. Try putting this code into your console and running it. 

var cities = ['Gainesville', 'Tampa Bay', 'Orlando', 'Miami'];
print(cities);

If you look at the output in the Console, you will see “List” with an expander arrow (▹) next to it. Clicking on the arrow will expand the list and show you its content. You will notice that along with the four items in the list, there is a number next to each value. This is the index of each item. It allows you to refer to each item in the list using a numeric value that indicates its position in the list.

Output from Google Earth Engine After running the script