What do null and undefined mean in JavaScript

Published on Mar 27, 2022

Undefined in JavaScript refers to a variable that has been declared but not yet assigned a value

var a;
console.table(a) //shows undefined

An assignment value is null. It can be assigned to a variable as a no-value representation.

var a= null;
console.table(a); //shows null

Undefined and null are two distinct types, as shown in the preceding examples: undefined is a type (undefined), whereas null is an object.

null === undefined //false
null == undefined //true
null === null //true
null = 'value' //ReferenceError
undefined = 'value' // 'value'