Skip to main content
JavaScript Interview Questions Predict Output P0 Medium

Three typeof checks

Predict each line. For the last check, name the error type if there is one.

Official Reference

Code Snippet

const value = "outer";
function probe() {
  console.log(typeof spare);
  var spare = 7;
  console.log(typeof notDeclaredHere);
  try {
    console.log(typeof value);
    const value = 9;
  } catch (error) {
    console.log(error.name);
  }
}
probe();

Expected Output & Explanation

undefined
undefined
ReferenceError

spare already exists with value undefined. typeof safely handles the missing name, but the inner value shadows the outer value and is still uninitialized. The first two printed values are strings.

Module Context & References

JavaScript · Language output drills Trace closures, receivers, prototypes, coercion and array edge cases
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.