Skip to main content
JavaScript Interview Questions Predict Output P0 Medium

Nullish checks and destructuring defaults

Predict which fallback applies to 0, null and a missing property.

Official Reference

Code Snippet

const source = { retries: 0, delay: null };
const { retries = 2, delay = 100, timeout = 200 } = source;
console.log(retries, delay, timeout);
console.log(retries || 5, retries ?? 5, delay ?? 5);

Expected Output & Explanation

0 null 200
5 0 5

Destructuring defaults apply only to undefined, including a missing property. || falls back on a falsy value, while ?? falls back only on null or undefined.

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.