Two containers that everything stands on
Real data rarely lives alone: a list of orders, a client card, a transaction history. To store it, languages have two basic containers:
- Array (list) — an ordered sequence: orders, file lines, coins in a portfolio.
- Object (dictionary) — a set of "key → value" pairs: a card with fields.
90% of any program's data is a combination of these two containers.
Arrays
The main quirk everyone trips over: numbering starts at zero. The first element is [0], the fifth is [4]. Accessing out of bounds (coins[100]) gives undefined in JS and an error in Python.
Objects (dictionaries)
When data has named fields, an array is awkward — you need an object:
The language difference: JS accesses fields with a dot (order.id), Python with a key in brackets (order["id"]). The essence is the same: the value is fetched by name, not by number.
The main structure of real data
The combination "array of objects" is the form almost everything arrives in: table rows, API responses, user lists. Processing is a loop over the array with access to fields:
This pattern — a loop over an array of objects with a condition and an accumulator — you'll write (and read in AI code) more often than any other.
Exercise
Find the largest order in the list and print the client's name. Hint: set up two variables — the maximum and the name, update both in the loop when you meet an order bigger than the current maximum.
Key takeaways
- An array is an ordered list, access by index from zero; an object has fields by name.
- JS:
order.id; Python:order["id"]— the essence is one. - An array of objects is the form of 90% of real data.
- The pattern "loop + fields + condition + accumulator" is the most common in practice.