Do you often find that you have no idea whether your variable contains a string or a number? Either your data comes from user input, an API, or some file-like source. If it's user input, say from an <input>, you would already know to parseInt(). If it's from an API then presumably it's conforming to a documented spec. If it's from a file or something less than conformant, safely parse it.
Why/how would you get to the point where you're operating on the value without being certain of its type?
> Why/how would you get to the point where you're operating on the value without being certain of its type?
My favorite example of this is the twitter API, which used to report retweet count as the string "100+" for the case of over 100 retweets. This behavior was not documented [1], so until you encounter that example, you wouldn't necessarily expect this or defend against a string
How could === defend you in this case? `"100+" != 100` already.
If you do a typeof before further processing the value then you'll know how to treat it, and additionally someone who comes after you will realize that the value could be a number or a string.
Instead of using === everywhere, if you parse and cast your input to known types you also have the opportunity to catch errors where input is not conforming.
Your parsing makes it obvious to other programmers what your assumptions are about the input. With === all a person will see is that the expected condition did not trigger but no obvious reason why. If `key === 13` fails all we know is that there is no strict equality, but `parseInt(key) == 13` failing means that key is not something which could parse to number 13, and consequently what type(s) key can be is obvious.
Moreover with parseInt the left side of that operator will always be a number or NaN, and the right side is a scalar, so there is no justification for using `parseInt(key) === 13`. It would be preposterous. If you can't trust the return type of parseInt, then your programming environment is unreliable.
Why/how would you get to the point where you're operating on the value without being certain of its type?