codecks.

JavaScript output practice

Follow the
next step.

Before running a snippet, write down what each line changes and what it schedules. Three checks will get you through the practice decks.

Draw references when you copy an object.

Spreading an object makes a new outer object. A property holding an array or another object still points to the same nested value. Mark that shared reference before you trace a mutation. For an array, check whether the method changes the array itself or returns a new one. MDN on shallow copies.

Find the binding a function reads.

A closure retains access to its surrounding bindings. Ask whether the function reads a shared variable at call time, a separate binding for each loop iteration, or state from a separate factory call. If you see a block-local let declaration, check whether a read happens before that binding is initialized. MDN’s closure guide.

Keep a queue beside the synchronous work.

In a browser script, finish the current synchronous work, drain microtasks such as promise reactions, and then move to the next task such as a timer callback. An async function runs up to its first await before returning control to its caller. MDN’s JavaScript execution model.

console.log("start");
setTimeout(() => console.log("later"), 0);
Promise.resolve().then(() => console.log("ready"));
console.log("end");

The synchronous lines log start and end. The promise reaction is ready in the microtask queue, so it logs ready before the timer task logs later. A zero delay still schedules a later task.

Say what is logged, then check the explanation.

Each Codecks card prints primitive values or an explicitly joined array, making the expected text clear. Pick an answer, step through the highlighted lines, and use the reference to check the rule. Progress stays in your browser and can be downloaded to resume elsewhere.

Start a practice session