An empty value is distinct from undefined.
An empty string has a valid value and a defined type.
let car = “”; typeof car; |
In JavaScript, null represents “nothing” and is intended to signify the absence of existence.
However, in JavaScript, the data type of null is an object.
You can clear an object by assigning it a value of null.
// Create an Object let person = {firstName:“John”, lastName:“Doe”, age:50, eyeColor:“blue”}; person = null; // Now value is null, but type is still an object |
You can also clear an object by assigning it the value of undefined.
let person = {firstName:“John”, lastName:“Doe”, age:50, eyeColor:“blue”}; person = undefined; // Now both value and type is undefined |
You can also clear an object by assigning it the value of undefined
.
typeof undefined // undefined typeof null // object null === undefined // false null == undefined // true |