@[email protected] to Science [email protected]English • 2 months agoif statement == falsei.imgflip.comimagemessage-square39fedilinkarrow-up1246arrow-down118starcopymore-verticalflagCreate ReportslashBlock user
arrow-up1228arrow-down1imageif statement == falsei.imgflip.com@[email protected] to Science [email protected]English • 2 months agomessage-square39fedilinkstarcopymore-verticalflagCreate ReportslashBlock user
minus-square@[email protected]linkfedilinkEnglish3•2 months 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? arrow-up13arrow-down10file-textreply1starmore-verticalmailMessageflagCreate ReportslashBlock user
minus-squareAdmiral PatricklinkfedilinkEnglish1•edit-22 months agoIt’ll give you 1 ~= true or 0 ~= undefined, but I typically use Typescript which prefers actual booleans to boolean-ish arrow-up11arrow-down10file-textreply1starmore-verticalmailMessageflagCreate ReportslashBlock user
minus-square@[email protected]linkfedilinkEnglish1•2 months agohuh. interesting. i wonder what number it’s actually storing for false then? arrow-up11arrow-down10file-textreply1starmore-verticalmailMessageflagCreate ReportslashBlock user
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?