for...of
for...of walks through an array (or any iterable) and hands you each value, one per turn.
for (const tag of tags) { reads: "for each tag of tags". On each turn, tag holds the next value and the block runs.
You use const because each turn creates a fresh variable: you read it, you don't reassign it. There is no counter to manage and no index that can go out of range.
It works with arrays, strings, Map and Set: anything iterable. It does not work on a plain object.
In TypeScript, the type checker infers the type of tag from the array: if tags is string[], tag is string. That type is gone when Node runs the code; only the loop remains.
The course uses it from lesson 01.04 on, to walk through lists of data.
Reach for it when: you need to do something with every item of an array and its position doesn't matter.
Examples
Common mistake
const user = { name: "Ana", age: 30 };
for (const value of user) {
console.log(value);
}Why: A plain object is not iterable, so `for...of` doesn't know how to walk it.
How to write it: Loop over Object.values(user), Object.keys(user) or Object.entries(user), which return arrays.
