Collections
The big question: “How arrays and objects REALLY work: memory, O(1), hashing, references”
With one variable per value, a list of 200 test results would need 200 separate variables — result1 through result200 — and a loop couldn’t even visit them one by one. Real data comes in groups, so programs need containers for groups: arrays for ordered lists, objects for labeled bundles. Every API response and every test report you’ll ever handle is built from these two.
One jar per value is fine for age — but real data comes in groups: a list of 200 test results, a user with a name, email and password. Arrays are ordered lists (numbered shelf slots); objects are labeled bundles (a locker with named drawers).
This phase also holds the single most important “gotcha” in JavaScript: for arrays and objects, a variable’s box doesn’t hold the thing itself — it holds an arrow pointing to it. Copy the variable and you copy the arrow, not the thing. Two names, one object. Change it through either name and “both” change.
That one picture — arrows, not things — explains an entire family of bugs you will absolutely meet in real test code. You’ll see it animated until it’s impossible to forget.
An ordered list of values on numbered shelf slots. Counting starts at 0.
A slot’s number in an array. The first item is index 0.
A bundle of labeled values: { name: "Lijas", role: "tester" }. Each label is a key, each content a value.
The “arrow” a variable holds instead of the object itself. Copying the variable copies the arrow — both point at the same object.
Changing an object or array in place. Everyone holding an arrow to it sees the change.
A text format for shipping objects around — how servers and tests exchange data. You’ll live in it as an automation tester.
- ✓Store and read grouped data with arrays and objects
- ✓Draw the arrows: predict when changing one variable affects another
- ✓Transform lists with map, filter and reduce — and narrate each step
- ✓Read and write JSON comfortably
✏️ This phase’s interactive lab is still being drawn — it arrives together with the phase’s lessons.
- 4.1Arrays
One name, many values — elements in order, found by index.
- 4.2Inside an array: memory & O(1)
Contiguous slots, address = start + index × size — why lookup is one jump at any size.
- 4.3Growing & shrinking
push, pop, shift, unshift — and the O(n) bill for front-of-array work.
- 4.4Objects
Properties: key → value. Fetch by name, not position — dot vs brackets.
- 4.5Inside an object: the hash trick
How a WORD becomes an address: hash function → bucket → O(1) by name. Hello, hash maps.
- 4.6Primitives vs references
THE lesson: call by value vs call by sharing — what really copies when you write b = a.
- 4.7Copying & equality
Shallow vs deep copies, spread — and why {} !== {}.
- 4.8Iterating collections
for...of, for...in, and Object.keys / values / entries.
- 4.9map / filter / reduce
The transform trio — every element’s journey down the belt.
- 4.10Sorting & finding
sort’s string-default gotcha, find, some, every, includes.
- 4.11Destructuring, spread & rest
Patterns that mirror shapes — and the options-object style every modern API uses.
- 4.12Map & Set
The uniqueness door, and keys of any type — the hash map, offered as dedicated tools.
- 4.13JSON
The wire format of every API — flatten an object to text, rebuild it back.
- 4.14Checkpoint: test-results dashboard
filter → map → reduce over real run data — your first QA dashboard.