Drycodez Posted September 20, 2011 Share Posted September 20, 2011 Why is 'null' considered as object? document.write(typeof null)//display: Object. Link to comment Share on other sites More sharing options...
Ingolme Posted September 20, 2011 Share Posted September 20, 2011 Here's what I got from Mozilla's Developer Network:https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special/typeof#null In the first implementation of JavaScript, JavaScript values were represented as a type tag and a value. The type tag for objects was 0. null was represented as the NULL pointer (0x00 is most platforms). Consequently, null had 0 as type tag, hence the bogus typeof return value. (reference needed)This is planned on being fixed in the next version of ECMAScript (which will be available via an opt-in). It will result in typeof null === 'null'. Link to comment Share on other sites More sharing options...
Drycodez Posted September 20, 2011 Author Share Posted September 20, 2011 K, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.