const emptyValue = null;
let pending;
console.log(typeof emptyValue);
console.log(typeof pending);The two lines show the real behaviour: object for null and undefined for the uninitialized binding.
LESSON 08 OF 50
Compare the historical typeof results for null and undefined.
undefined is used when a binding has no assigned value yet. null is an intentional primitive value; however, for historical reasons, typeof null returns “object”.
const emptyValue = null;
let pending;
console.log(typeof emptyValue);
console.log(typeof pending);The two lines show the real behaviour: object for null and undefined for the uninitialized binding.
const emptyValue = 'null';
let pending = 'undefined';The texts “null” and “undefined” are strings, not the corresponding primitive values.
Declare emptyValue as null and pending without a value; print typeof for both in that order.
Run the code to see the result.The declarations create distinct values, and typeof reveals both the difference and the historical null exception.
ANALYSIS REQUEST
The initial discussion is without obligation. You receive an honest recommendation, suitable stages and the factors that affect price.