DEV Community

prototype, __proto__ and Prototypal inheritance in JavaScript

Varun Dey on August 11, 2019

This post was originally published on my website If you have spent some time with JavaScript, chances are that you have already seen or atleast ...
Collapse
 
schusterbraun profile image
Schuster Braun

Just because I ran into this earlier this week I wanted to let you know that null actually is an object. Sry to be the well actually guy. Wish I could down vote my own comment. But couldn't help myself. Just wanted to share knowledge. Gr8 article.

Collapse
 
varundey profile image
Varun Dey

Hey Schuster, there's no harm with sharing information. 😄 Thanks for reading, I hope this was informative. I was not sure if I should point it in this article as this is not entirely related to prototype inheritance - (and I hate to be that guy as well 😅) null is not an Object. It is a separate primitive in JavaScript. The reason why typeof null returns Object is a legacy bug in JavaScript which can't be fixed. More on this - 2ality.com/2013/10/typeof-null.html

Collapse
 
ferozkhansikkandar profile image
Feroz Khan

You can consider it a bug in JavaScript that typeof null is an object. It should be null.

Collapse
 
bhansa profile image
Bharat Saraswat

Thanks for writing this post Varun, its great. Looking forward to read your next article :)

Collapse
 
varundey profile image
Varun Dey

Thanks for the kind words Bharat. :)