null is null or is not an object

I stumbled upon this javascript error in IE7 today.

Shouldn’t it be null is null and is not an object ?

CategoriesUncategorizedTags

3 Replies to “null is null or is not an object”

  1. of coz “typeof null” should return ‘null’. Unfortunately it returns ‘object’ as ECMAScript spec. Brendan Eich confirmed that it’s a mistake, but it’s too late to fix it. Let’s waiting for ECMAScript edition 6 or 7 to fix it…

  2. I dont think that’s a mistake, as it makes an easy way to return an empty ‘error’ object.
    What I dont understand is why there is upper+lowercase number, string and boolean… or why classes also return object, and you need toString() to get the real type…

    var n = 5; // typeof n == ‘number’
    var m = new Number(5); // typeof m == ‘Number’

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.