Skip to content
Justice Tech School

null and undefined

undefined means no value was assigned. null is an intentional empty value you set yourself. Use === to tell them apart and ?? to supply defaults.

Example
let a;
const b = null;
console.log(a, b, a == b, a === b);
console.log(a ?? "default", b ?? "default");

Exercise

Default for null or undefined.

x  "none"

Quiz Test

Do undefined and null compare equal with ===?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.