sorrybookbroke@sh.itjust.works to Programmer Humor@lemmy.mlEnglish · edit-21 year ago"m=!0"... What the hell am I looking at?sh.itjust.worksimagemessage-square12fedilinkarrow-up150arrow-down123
arrow-up127arrow-down1image"m=!0"... What the hell am I looking at?sh.itjust.workssorrybookbroke@sh.itjust.works to Programmer Humor@lemmy.mlEnglish · edit-21 year agomessage-square12fedilink
minus-squarelastunusedusername2@sh.itjust.workslinkfedilinkEnglisharrow-up62·1 year agoIt looks like it’s just assigning the scope variable m to true (also false in the m=!1 case. It’s minified code and m=!0 is fewer characters than m=true.
minus-square📛Maven@lemmy.sdf.orglinkfedilinkEnglisharrow-up12arrow-down1·1 year agoWell I hate that. Is there a reason m=1 wouldn’t be the same thing as m=!0?
minus-squareHack3900@lemdit.comlinkfedilinkEnglisharrow-up40·1 year agoTypes are dynamic so I think the ! operator converts int to bool in JS
minus-squareHeavybell@lemmy.worldlinkfedilinkarrow-up30·1 year ago1 is truthy, but not the exact same thing as true, and the distinction can be important.
minus-squareInvertedParallax@lemm.eelinkfedilinkarrow-up9·1 year ago1 != true, 1 is an int, true is a boolean
It looks like it’s just assigning the scope variable
m
totrue
(alsofalse
in them=!1
case.It’s minified code and
m=!0
is fewer characters thanm=true
.Well I hate that. Is there a reason
m=1
wouldn’t be the same thing asm=!0
?Types are dynamic so I think the ! operator converts int to bool in JS
1 is truthy, but not the exact same thing as true, and the distinction can be important.
1 != true, 1 is an int, true is a boolean
deleted by creator