I stumbled upon this javascript error in IE7 today.
Shouldn’t it be null is null and is not an object ?
Related
3 Replies to “null is null or is not an object”
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…
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’
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…
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’
I think they said that will change that.