What is the output of the following code: console.log(typeof null);?
a) “object”
b) “null”
c) “undefined”
d) “boolean”
Answer:
a) “object”
Explanation:
In JavaScript, the typeof
operator returns “object” when applied to null
. This is considered a quirk in JavaScript, as null
is generally treated as a separate data type.
Example:
console.log(typeof null); // Output: "object"