DEV Community

Cover image for "Unveiling JavaScript's Puzzling Quirk: The Object Identity of Null"

"Unveiling JavaScript's Puzzling Quirk: The Object Identity of Null"

BIKI DAS on June 15, 2023

In the realm of frontend interviews, the question of typeof(Object) has left many developers scratching their heads. We've all experienced the puzz...
Collapse
 
tracygjg profile image
Tracy Gilmore • Edited

Hi Biki,

Is null the only falsy Object?

console.log(!!null); // false

console.log(typeof null); // object 

console.log(!!{}); // true

const isNull = subject => typeof subject === 'object' && !subject;

const isObject = subejct =>  typeof subject === 'object' && !!subject;
Enter fullscreen mode Exit fullscreen mode

Tracy

Collapse
 
j4k0xb profile image
j4k0xb

Image description