Hacker News new | ask | show | jobs
by fzzzy 856 days ago
Just always use !==. != will automatically cast and !== won't, therefore "1" != 1 is false and "1" !== 1 is true.
1 comments

Unless you’re testing if something is null or undefined, in which case a single “x != null” handles it.
Sure. I usually just use !x for that.
That doesn't test if it's null or undefined, that just tests if it's not falsy.

x = 0; !x → true

y = ""; !y → true

z = null; !z → true