Select Page
let dog;
console.log(dog);

This produces undefined. Undefined comes when you try and access a variable that’s been created but not set.

Null is a value of nothing. Undefined is a value of a variable that has not yet been assigned a value.

Examples:

let exampleUndefined; (can’t const something that
const exampleNull = null;

A null value has to be explicitly set to null.

They are both nothing, but they are nothing in a different way.