676
=== (programming.dev)
you are viewing a single comment's thread
view the rest of the comments
[-] kevincox@lemmy.ml 2 points 8 months ago

I just tested and Terser will convert v === null || v === undefined to null==v. Personally I would prefer to read the code that explicitly shows that it is checking for both and let my minifier/optimizer worry about generating compact code.

[-] SzethFriendOfNimi@lemmy.world 0 points 8 months ago

Try changing to const === variable. That’s most likely what’s it doing to minimize the risk of accidental assignment.

[-] kevincox@lemmy.ml 3 points 8 months ago

Wut? This is an automated optimizer. It is not worried about accidental assignment.

[-] SzethFriendOfNimi@lemmy.world 1 points 8 months ago

I agree it shouldn’t. But I’ve seen linters that automatically change it since they seem to be forcing practical conventions sometimes.

[-] kevincox@lemmy.ml 3 points 8 months ago

Linters and minifers are completely different tools.

[-] SzethFriendOfNimi@lemmy.world 3 points 8 months ago

Good point. That’s what I get for shooting from the hip.

Thanks!

this post was submitted on 25 Jan 2024
676 points (97.6% liked)

Programmer Humor

19331 readers
445 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS