JPDev@programming.dev to Programmer Humor@programming.dev · 1 年前===programming.devimagemessage-square79fedilinkarrow-up1690arrow-down117
arrow-up1673arrow-down1image===programming.devJPDev@programming.dev to Programmer Humor@programming.dev · 1 年前message-square79fedilink
minus-squarekevincox@lemmy.mllinkfedilinkarrow-up2·1 年前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.
minus-squareSzethFriendOfNimi@lemmy.worldlinkfedilinkarrow-up1arrow-down1·1 年前Try changing to const === variable. That’s most likely what’s it doing to minimize the risk of accidental assignment.
minus-squarekevincox@lemmy.mllinkfedilinkarrow-up3·1 年前Wut? This is an automated optimizer. It is not worried about accidental assignment.
minus-squareSzethFriendOfNimi@lemmy.worldlinkfedilinkarrow-up1·1 年前I agree it shouldn’t. But I’ve seen linters that automatically change it since they seem to be forcing practical conventions sometimes.
minus-squarekevincox@lemmy.mllinkfedilinkarrow-up3·1 年前Linters and minifers are completely different tools.
minus-squareSzethFriendOfNimi@lemmy.worldlinkfedilinkarrow-up3·1 年前Good point. That’s what I get for shooting from the hip. Thanks!
I just tested and Terser will convert
v === null || v === undefined
tonull==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.Try changing to const === variable. That’s most likely what’s it doing to minimize the risk of accidental assignment.
Wut? This is an automated optimizer. It is not worried about accidental assignment.
I agree it shouldn’t. But I’ve seen linters that automatically change it since they seem to be forcing practical conventions sometimes.
Linters and minifers are completely different tools.
Good point. That’s what I get for shooting from the hip.
Thanks!