Hacker News new | ask | show | jobs
by paracaidista 4198 days ago
== vs. === aside, it's a bit hypocritical to use === because it's safer when you're using undefined as a keyword. You can't tell just from looking at that line whether the variable undefined is actually undefined or not; it could, in fact, be defined (below the global scope, that is -- unless you're in an older browser, I suppose).

Granted, defining a variable called undefined would be absurd, and I realize I'm nitpicking here, but if we're trying to make a point about good practice, typeof would be the way to go. (Of course, more often you only really care if something == null or not, so you'd just do a simple == null check, like you said.)