You know what hoisting and closures are. Explaining them out loud, while an interviewer waits, is a different skill.
Last year I wrote about an interview I almost failed because of that gap. Here's how I put it then:
"The interviewer hit me with tough questions on Hoisting and Closures in JavaScript. I knew the terms, but couldn't explain them clearly."
Most interview prep trains you to recognize answers. You read a question, read the answer, nod, and move on to the next one. Nodding along feels like knowing the answer.
For the past few months I've been building a course that trains you to explain them. It's called The Senior JavaScript Interview, and it opens on Monday 23 November. You answer each question out loud before you see the model answer, so you find the ones you can't explain yet while there's still time to fix them. By the interview, you've said the senior answers out loud at least once.
Try one question first
This one comes from the async chapter, and it's tagged Senior. Answer it out loud before you scroll.
Why doesn't array.forEach(async (x) => await work(x)) wait for the work to finish?
Once you have your answer, here's the core of the model answer.
forEach ignores what its callback returns. Each async callback returns a promise, forEach throws that promise away, and the loop finishes while the work is still pending. A rejection goes unhandled too.
// waits for every save, and a rejection reaches the caller
await Promise.all(items.map((item) => save(item)));
// or one at a time, if order matters
for (const item of items) await save(item);Most answers stop there. The model answer keeps going, because map, filter and reduce don't await either. An async filter predicate is a silent bug. A promise is always truthy, so every item passes the filter.
That second half is what the Senior tag is about. The first half shows you know the bug, and the second half shows where else it hides in your codebase.
How the course works
The Senior JavaScript Interview has 660+ questions and architecture scenarios on React, Node.js, TypeScript and system design. Every question is tagged Junior, Mid or Senior, so you know which level it tests.
The web reader hides each model answer until you've given your own, the same way you just answered the question above. There are 49 architecture scenarios with model answers, and every scenario ends with what the interviewer is grading.
3 chapters are free today
The free sample has 3 full chapters, exactly as they appear in the course: Async JavaScript, the React rendering model and Node.js API design. That's 76 questions and 3 architecture scenarios, with a five-question self-test at the end of each chapter. The question above is one of them.
Take the sample before Friday 20 November, and you get checkout that day, three days before everyone else, at the launch price.
You enter your email on my site, confirm it, and the chapters arrive right after, as a web reader and an EPUB. That also puts you on my email list at petarivanov.tech. One click unsubscribes you from that list, and you keep the chapters.
Launch prices run until Monday 30 November at 23:59 PT: $79 for Standard, which covers the technical rounds, and $149 for Premium, which adds the interview itself. After that, they're $119 and $229. Prices are plus VAT where it applies.
Thank you for supporting this newsletter.
Petar

