7 ms·
It is correct to say that typeof(null) returns the string 'object' because of a bug that is now written into the standard to prevent old software from "breaking
by raganwald 13y ago
It is correct to say that typeof(null) returns the string 'object' because of a bug that is now written into the standard to prevent old software from "breaking" if they fixed this.
It is not ever correct to say that null in JavaScript is an object. Just ask javaScript itself:
Object.getPrototypeOf(null)
//=> TypeError: Object.getPrototypeOf called on non-object