Hacker News new | ask | show | jobs
by hellcow 856 days ago
Unless you’re testing if something is null or undefined, in which case a single “x != null” handles it.
1 comments

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