The main difference between null and undefined in JavaScript is their meaning and how they’re assigned.
undefinedmeans a variable has been declared but not assigned any value.nullmeans a variable has been intentionally assigned an empty or “no value” state.
🧾 Example:
let a;
console.log(a); // undefined (no value assigned)
let b = null;
console.log(b); // null (explicitly assigned no value)
✅ In short:
undefined→ the variable exists but has no value yet.null→ the variable was given an empty value on purpose.