tatterdemalion@programming.dev to Science Memes@mander.xyzEnglish · 21 days agoif statement == falsei.imgflip.comimagemessage-square40fedilinkarrow-up1249arrow-down118
arrow-up1231arrow-down1imageif statement == falsei.imgflip.comtatterdemalion@programming.dev to Science Memes@mander.xyzEnglish · 21 days agomessage-square40fedilink
minus-squarejuliebean@lemm.eelinkfedilinkEnglisharrow-up3·16 days agodoes javascript not allow you to interpret integers as booleans in a conditions directly? seems it’d be simpler to just do math.round(math.random()), which should still get you true (1) or false (0) in equal likelihood. or am i missing something?
minus-squareAdmiral Patrick@dubvee.orglinkfedilinkEnglisharrow-up1·edit-216 days agoIt’ll give you 1 ~= true or 0 ~= undefined, but I typically use Typescript which prefers actual booleans to boolean-ish
minus-squarejuliebean@lemm.eelinkfedilinkEnglisharrow-up1·16 days agohuh. interesting. i wonder what number it’s actually storing for false then?
does javascript not allow you to interpret integers as booleans in a conditions directly? seems it’d be simpler to just do math.round(math.random()), which should still get you true (1) or false (0) in equal likelihood. or am i missing something?
It’ll give you 1 ~= true or 0 ~= undefined, but I typically use Typescript which prefers actual booleans to boolean-ish
huh. interesting. i wonder what number it’s actually storing for false then?