JS

JAVASCRIPT NULL vs UNDEFINED vs EMPTY

EXPLICITLY USED TO DEFINE “NOTHING” OR “ABSENT”. var people = ["Jon", "Joy", null];   DATATYPE console.log(typeOf null); OBJECT

NULL VALUES

01

COMPARISON null == undefined TRUE null === undefined FALSE null == "" FALSE null === "" FALSE

A VARIABLE WITHOUT ASSIGNED VALUE var people;   DATATYPE console.log(typeOf undefined); UNDEFINED

UNDEFINED VALUES

02

COMPARISON undefined == null TRUE undefined === null FALSE undefined == "" FALSE undefined === "" FALSE

AN EMPTY STRING var people = "";   DATATYPE console.log(typeOf ""); STRING

EMPTY STRINGS

03

COMPARISON "" == null FALSE "" === null FALSE "" == undefined FALSE "" === undefined FALSE