Sleepless One@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 6 days agoThe JavaScript type coercion algorithmlemmy.mlimagemessage-square45fedilinkarrow-up1126arrow-down12file-textcross-posted to: [email protected]
arrow-up1124arrow-down1imageThe JavaScript type coercion algorithmlemmy.mlSleepless One@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 6 days agomessage-square45fedilinkfile-textcross-posted to: [email protected]
minus-squareTelemachus93@slrpnk.netlinkfedilinkarrow-up3·5 days agoIn other languages that shouldn’t be equal either though, right? Maybe you meant if (2){ console.log("nonzero ints are truthy") } else { console.log("no they're not") } Which would output nonzero ints are truthy and that would actually work in all languages I know. But that’s different from being equal.
minus-squareretrolasered@feddit.uklinkfedilinkEnglisharrow-up2·5 days agoYeah its checking for not null with if isnt it. Maybe thats what has me confused
In other languages that shouldn’t be equal either though, right?
Maybe you meant
if (2){ console.log("nonzero ints are truthy") } else { console.log("no they're not") }
Which would output
nonzero ints are truthy
and that would actually work in all languages I know. But that’s different from being equal.
Yeah its checking for not null with if isnt it. Maybe thats what has me confused