Skip to content

predict · control

A throw, three frames deep.

Answer before anything runs. Then the machine runs it, and you can step through what it did.

const trail = [];
function inner() {
  trail.push("inner");
  throw new RangeError("out of range");
}
function middle() {
  trail.push("middle");
  inner();
  trail.push("never");
}
let caught = "none";
try {
  middle();
} catch (error) {
  caught = error.constructor.name;
}
const depth = trail.length;
What does `caught` hold when the program has finished?
What does `depth` hold when the program has finished?