1117
you are viewing a single comment's thread
view the rest of the comments
[-] Skyhighatrist@lemmy.ca 14 points 1 year ago

That's not true these days. You can try it yourself right in your browser's dev console.

These results are from Firefox's console.

0 == null == undefined
> false
0 == null
> false
0 == undefined
> false
null == undefined
> true
null === undefined
> false

And even in the one case where == says they are the same, you can fix that by making sure you are using === so that it doesn't do type coercion for the comparison.

[-] shrugal@lemm.ee 2 points 1 year ago* (last edited 1 year ago)

Shhhhh, bashing Javascript is cool around here.

[-] JackbyDev@programming.dev 1 points 1 year ago

Just make fun of it for having two flavors of null.

[-] shrugal@lemm.ee 2 points 1 year ago

So what's wrong with having two flavors of null?

[-] JackbyDev@programming.dev 2 points 1 year ago

It's super confusing. A lot of people think even one null is a problem.

[-] shrugal@lemm.ee 2 points 1 year ago

What's confusing about that? It's null, just two different kinds with slightly different meanings. Is having two boolean values also confusing?! Should we simplify it?

I mean I can get behind trying to remove null entirely and replacing it with better concepts, but I cannot understand why having one more null value suddenly makes it confusing. You don't even have to care in 95% of the cases, and it can be useful in the other 5%.

Honestly, it looks more like some kind of misguided purism to me.

[-] JackbyDev@programming.dev 1 points 1 year ago

Why stop at two? Why not have a dozen versions of null?

[-] shrugal@lemm.ee 1 points 1 year ago* (last edited 1 year ago)

Idk, how many more do you need?

this post was submitted on 05 Oct 2023
1117 points (97.0% liked)

Programmer Humor

32155 readers
212 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS