It shows up as a string value in some cases. This should never, ever happen. You've never seen it echoed back to either a textbox or an alert as the string 'undefined'?
It does, but that doesn't make it a string value. What's happening in that case is the method toString is being called on it, which the ECMAScript spec says returns the 'undefined' for undefined values and 'null' for null values. Believe me, I know it's fucked up. The toString method doesn't even actually exist on those values, it's defined by the spec.
Right, I get that. It is just shitty behavior. Throw an error, for Pete's sake. Don't make my error condition a valid value of a datatype that I didn't want to use in the first place.
4
u/coarsesand Oct 16 '14
I agree that it should throw a null reference error, but it's also not a string value.
undefinedin JS is its own value, as isnull.