By Hemanta Sundaray on 2021-07-12
null is a primitive data type in JavaScript. It indicates that a variable points to no object.
// count exists, but it has no type or value
let count = null
console.log(null)
// null
undefined is a primitive data type in JavaScript. It indicates that a variable has not been assigned any value.
// count has been defined, but not initialized
let count
console.log(count)
// undefined
Another way to think about null & undefined is as follows:
undefined: Used for unintentionally missing values
null: Used for intentionally missing values