Concept
A ? after a parameter name makes it optional, and = gives it a default. Both let one function serve the common case and the detailed one without overloads.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Optional and default parameters doing its job.
function paginate(items: string[], size = 10, page?: number) {
const start = ((page ?? 1) - 1) * size;
return items.slice(start, start + size);
}
paginate(list); // first 10
paginate(list, 25); // first 25
paginate(list, 25, 3); // third page of 25Checking an optional parameter with if (!page) when 0 or "" is a valid value. The falsy check treats them as missing; compare with undefined or use ?? instead.
Your roadmap puts these before Optional and default parameters, unless you already know them.
Once a session shows you understand Optional and default parameters, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.