cf.completefrontend

Predict the outputMedium

This catch handles only one kind of error. What gets logged?

What does this log?
class NotFoundError extends Error {}
 
function findUser(id) {
  if (typeof id !== "number") throw new TypeError("id must be a number");
  throw new NotFoundError(`No user ${id}`);
}
 
function findUserOrNull(id) {
  try {
    return findUser(id);
  } catch (error) {
    if (error instanceof NotFoundError) return null;
    throw error;
  }
}
 
console.log(findUserOrNull(7));
console.log(findUserOrNull("7"));
console.log("done");

The answer

Work out every line it logs, in order. Then check.

Checking your sign-in…