Utilizor
Contact Us

undefined vs null

The difference between undefined and null.

undefined vs null

undefined

undefined is the type of a variable that has not been assigned a value.

null

null is an object. It is supposed to be something that doesn't exist.

Difference

typeof undefined is "undefined".

typeof null is "object".

null === undefined is false.

null == undefined is true.

Example

let x; // undefined
let y = null; // null