I recently came across the following line of code:
var type = (typeof x).toLowerCase();
Note that in the above code, x will only be a string, number or undefined. I questioned this by pointing out that the specification (11.4.3) asserts the values returned by the typeof operator, and all of them are already lowercase.
It is worth noting that the specification leaves the host objects free to return almost everything they like, so in this case you can get a string with some uppercase letters (I do not actually do this ever, but it is allowed). However, as already mentioned, in this case x is only a string, number or undefined.
My question is, do any typeof operator implementations ever return anything but a string string?
source share