return2ozma@lemmy.world to politics @lemmy.world · 9 个月前Texas Governor Greg Abbott declares that Texas law supercedes Federal authority and hints at secessionboingboing.netexternal-linkmessage-square326fedilinkarrow-up1805arrow-down123
arrow-up1782arrow-down1external-linkTexas Governor Greg Abbott declares that Texas law supercedes Federal authority and hints at secessionboingboing.netreturn2ozma@lemmy.world to politics @lemmy.world · 9 个月前message-square326fedilink
minus-squareTimeSquirrel@kbin.sociallinkfedilinkarrow-up17·edit-29 个月前Normal languages: “does this equal that?” JS: “does this REALLY equal that, or just ‘equal’ that?”
minus-squareRamblingPanda@lemmynsfw.comlinkfedilinkarrow-up10·9 个月前JS comparing a string and some random number: “ah, close enough probably”
minus-squareWrench@lemmy.worldlinkfedilinkarrow-up2arrow-down4·9 个月前Beats having explicit null checks everywhere.
minus-squareWrench@lemmy.worldlinkfedilinkarrow-up4arrow-down1·9 个月前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.
minus-squareRandelung@lemmy.worldlinkfedilinkarrow-up1·9 个月前Monads exist, optional chaining has been around for ages, and implicit bool casts, too. As you said, no one checks those values explicitly.
Ah ha, I found a JS dev lmfao
Normal languages: “does this equal that?”
JS: “does this REALLY equal that, or just ‘equal’ that?”
JS comparing a string and some random number: “ah, close enough probably”
Beats having explicit null checks everywhere.
As opposed to null and undefined?
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.
Monads exist, optional chaining has been around for ages, and implicit bool casts, too.
As you said, no one checks those values explicitly.