Why does typeof null misbehave in switch statements?
Posted
by user353366
on Stack Overflow
See other posts from Stack Overflow
or by user353366
Published on 2010-06-02T05:26:35Z
Indexed on
2010/06/02
5:33 UTC
Read the original article
Hit count: 198
It is commonly known that
typeof null
returns "object".
However, I have a piece of code that looks like this:
switch(typeof null){
case "object":
1;
default:
3;
}
This code returns 3.
Why does "object" as returned by typeof null not cause the first branch of the case statement to be executed?
© Stack Overflow or respective owner