Closed arb closed 5 years ago
Seems roughly equivalent in perf, OK for me.
I personally much prefer the consistency of using ===
everywhere. I'm also not convinced that this is actually a widely understood pattern. Using x === null || x === undefined
is explicit in what I would consider a very good way. If we want shorthand for checking null or undefined, maybe it's worth considering putting a utility in hoek.
My vote is to use x === null || x === undefined
for consistency.
Sucks for code coverage though, twice the test :p
Migrated from: https://github.com/continuationlabs/eslint-config-hapi/issues/34
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.