Conversation
Edited 5 months ago

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) 😓

5
0
3

@kasdeya you will be Happy ™ to know that MDN has a table for this!

1
0
2

I wish the language would let me write:

if (someFunc(args) of [null, undefined])

kinda like Python’s:

if someFunc(args) in [None, false]:
1
0
1

@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.

1
0
1

eli, shadow domme

Edited 5 months ago

@kasdeya (though, completely seriously, here is something more useful: the equality table for double equals)

2
1
3

@paul ngl I have some TypeScript code that looks like this because I had the bright idea to give a variable the unknown type since it was being parsed in from a JSON file lol, and tsc was being unbelievably picky about it

1
0
1

@rowan okay this is incredibly helpful - thank you! I’m really glad that I can someVar == null instead of (someVar ?? null) === null lol

0
0
1

@kasdeya
JS: Makes you question reality.
TS: Makes reality question you.

0
0
1

@kasdeya unfortunately the closest i think you can get to that specific syntax is [null, undefined].includes(someFunc(args))

0
0
1

@kasdeya

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.

0
0
0

@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

1
0
1

@kasdeya although if it's not particularly rigorous code, we'll just `if (!something)` and call it a day

0
0
1

@rowan @kasdeya my first thought was "it's cool how they paced their github commit history to be shaped like a crossbow"

0
0
1