At once weird and yet beautiful, it is surely the
programming language that Pablo Picasso would have invented. This post about some secrets and amazing fact of JavaScript.This facts and secretes helps to developers who are curious about
more advanced JavaScript. It is a collection of JavaScript’s oddities and well-kept secrets. I am going to prove you that every each of them can be explained.
Data Types And Definitions
Null is an Object
Null is apparently an object, which, as far as contradictions go, is right up there with the best of them. Null? An object? “Surely, the definition of null is the total absence of meaningful value,” you say. You’d be right. But that’s the way it is. Here’s the proof:alert(typeof null); //alerts 'object'Despite this, null is not considered an instance of an object. (In case you didn’t know, values in JavaScript are instances of base objects. So, every number is an instance of theNumberobject, every object is an instance of theObjectobject, and so on.) This brings us back to sanity, because if null is the absence of value, then it obviously can’t be an instance of anything. Hence, the following evaluates tofalse:alert(null instanceof Object); //evaluates false-