Say I wanted a function that checked whether or not a variable is a string, the interwebs advised me as follows:
function is_string(s) { return typeof s === 'string'; }
but I can't think of any scenario where "typeof s" could return "string" without s actually being a string.
Is there any reason for that === operator instead of ==?
Reason being, I want to check types in a switch statement, AFAIK, the switch statement uses the loose comparison operator. Since I'm only looking for known types and don't need to check for undefined, it should be fine, right?