Predict the output of the following javascript code
console.log(typeof typeof undefined);
Quiz Explanation
This quiz involves a bit of JavaScript type coercion and the behavior of the typeof
operator.
When you use typeof
with undefined
, it returns "undefined"
.
So, the expression typeof undefined
evaluates to "undefined"
.
Now, when you apply typeof
to the result of the first typeof
operation ("undefined"
), it returns the type of the string, which is "string"
.
Therefore, the output of the given code will be:
string