I am implementing a seemingly trivial utility function to check if a value is null
or undefined
.
My original implementation looked like this:
function isNil(value) {
return value === null || value === undefined;
}
I then looked up Lodash's implementation:
function isNil(value) {
return value == null
}
On the surface, this would seem like a naiive approach since it violates eslint's eqeqeq rule as well as only checking for null
.
I'm guessing that this approach works due to a combination of JavaScript's truthiness and equality rules, but is there actually an advantage to Lodash's implementation?