Closed arb closed 8 years ago
why not if (!value)
or if (value === null || value === undefined)
?
if (!value)
is not strictly equivalent.
I'm personally -1 on this, but it doesn't really matter anyway. This would have to get cleared in the hapi style guide.
Why are you -1 on this? I agree though, this would have to go up the ladder.
I don't like it because it is more consistent to just use ===
everywhere. This one exception only saves you a few characters. I think foo === undefined || foo === null
is faster too.
How about taking this up with the style guide (in hapijs/contrib I think), and if it gets OKed, I'll reopen this.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
I'd like to propose adding "allow-null" to the eqeqeq rule. This would allow for checks for values of
null
orundefined
to be done like:While it's generally not a great idea to let JS do whatever it wants during coercion, in this one instance, I think the trade off is worth it as checking
== null
is a pretty common and understood pattern.