Lists and Arrays, Ordered Sequences
So far each variable has held a single value. But programs work with many things: every student in a class, every book on a shelf, every transaction in a day.
A Python list and a JavaScript array are the same idea: an ordered sequence of values in one container. They're a direct equivalent, one of the cleanest translations between the two languages.
✦ Zero-indexing, one more time
Position 0 is first, position 1 is second. A list of 3 items has valid indexes 0, 1, and 2. Asking for index 3 is asking for a fourth item that doesn't exist, Python raises an IndexError, JavaScript quietly returns undefined.
Mark this lesson complete
Signed in, your progress follows you to every device.