Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
undefined | Better HN
0 points
hellcow
2y ago
0 comments
Share
Unless you’re testing if something is null or undefined, in which case a single “x != null” handles it.
0 comments
default
newest
oldest
fzzzy
2y ago
Sure. I usually just use !x for that.
SamBam
2y ago
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
j
/
k
navigate · click thread line to collapse