I’m low-key scared to use ==
in javascript tbh. like yes null == null
and undefined == null
but what else could == null
? I’m not about to sit in a REPL and exhaustively test everything in the langauge
I don’t even write if (booleanVar)
I write if (booleanVar === true)
😓
I wish the language would let me write:
if (someFunc(args) of [null, undefined])
kinda like Python’s:
if someFunc(args) in [None, false]:
@kasdeya
if (booleanVar === true && typeof booleanVar === 'boolean' && Object.prototype.toString.call(booleanVar) === '[object Boolean]') ad inf
Can never be too sure of what you're working with.
@kasdeya
JS: Makes you question reality.
TS: Makes reality question you.
It depends. Depending upon the code, at runtime, zero, null, and undefined can be treated as equal.
You must beat the interpreter into submission.
There is a great writeup on this, but I can not find it.
@kasdeya yeah . . . we do not use it unless we have the equality table pulled up to reference because it is definitely a weird edge case of the language
@kasdeya although if it's not particularly rigorous code, we'll just `if (!something)` and call it a day