0
()
submitted a long while ago by @ to c/@
you are viewing a single comment's thread
view the rest of the comments
[-] cm0002@lemmy.world 31 points 5 months ago* (last edited 5 months ago)

Ah ha, I found a JS dev lmfao

[-] TimeSquirrel@kbin.social 18 points 5 months ago* (last edited 5 months ago)

Normal languages: "does this equal that?"

JS: "does this REALLY equal that, or just 'equal' that?"

[-] RamblingPanda@lemmynsfw.com 10 points 5 months ago

JS comparing a string and some random number: "ah, close enough probably"

[-] Wrench@lemmy.world -2 points 5 months ago

Beats having explicit null checks everywhere.

[-] Randelung@lemmy.world 3 points 5 months ago

As opposed to null and undefined?

[-] Wrench@lemmy.world 3 points 5 months ago

No one checks those values explicitly.

if (str) checks if it's not null, undefined, or empty string.

Optional chaining like if (arr?.length) checks if list is undefined, null, or empty array.

Falsy and truthy comparators seem fucky in the beginning when coming from a strongly typed language. But they're very convenient when used properly.

[-] Randelung@lemmy.world 1 points 5 months ago

Monads exist, optional chaining has been around for ages, and implicit bool casts, too.

As you said, no one checks those values explicitly.

this post was submitted on 01 Jan 0001
0 points (NaN% liked)

0 readers
0 users here now

founded a long while ago