Y
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
hellcow
856 days ago
Unless you’re testing if something is null or undefined, in which case a single “x != null” handles it.
link
fzzzy
856 days ago
Sure. I usually just use !x for that.
link
SamBam
855 days 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
link