null vs undefined — JS Technical Interview Questions & Answers

Side-by-side comparison table.

null vs undefined

  • null vs undefined (diff) is a JS topic. In plain words you use it for a short null vs undefined diff example in a script in the browser. Don’t start with a slogan — start with that picture.
  • Smallest example: the smallest null vs undefined diff example you can type. Type it, run it, and say what you see. If you can do that from memory, you know null vs undefined (diff).
  • From the example next to this theory: Side-by-side comparison table.
  • Trap: only saying “null vs undefined diff” with no example. Fix that before you talk about advanced JS.
  • Viva: what is null vs undefined (diff)? Then show the smallest null vs undefined diff example you can type. Then name the trap.

Technical Interview Tip: What is null vs undefined (diff)? Show this: the smallest null vs undefined diff example you can type. Trap: only saying “null vs undefined diff” with no example.

Code Examples for null vs undefined

null vs undefined — working example

let missing;
const empty = null;
console.log(missing); // undefined — not assigned
console.log(empty);   // null — intentional empty
console.log(typeof missing, typeof empty);

null vs undefined — undefined means not assigned; null is an intentional empty value (typeof null is 'object').

How to Explain null vs undefined to an Interviewer

What is null vs undefined (diff)?

Used for a short null vs undefined diff example a script in the browser Not just the heading

Give one small example of null vs undefined (diff).

the smallest null vs undefined diff example you can type Side-by-side comparison table

What mistake do beginners make with null vs undefined (diff)?

only saying “null vs undefined diff” with no example Show the fix

Where do you use null vs undefined (diff)?

a script in the browser a short null vs undefined diff example