3 ms·
Removing a single character is hardly worth the issues that may arise from not using it. The only quasi-acceptable use of '==' IMHO is: myVar == null as i
by hajile 12y ago
Removing a single character is hardly worth the issues that may arise from not using it. The only quasi-acceptable use of '==' IMHO is:
myVar == null
as it is a little easier than:
myVar === undefined || myVar === null
That said, I use only '===' as I don't want to ever worry about my code (plus, the use of a maybe monad makes this and other problems go away).
- paracaidista 12y 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.)