Sleepless One@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 5 个月前The JavaScript type coercion algorithmlemmy.mlimagemessage-square45fedilinkarrow-up1115arrow-down11file-textcross-posted to: [email protected]
arrow-up1114arrow-down1imageThe JavaScript type coercion algorithmlemmy.mlSleepless One@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 5 个月前message-square45fedilinkfile-textcross-posted to: [email protected]
minus-squareTelemachus93@slrpnk.netlinkfedilinkarrow-up3·5 个月前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.
minus-squareretrolasered@feddit.uklinkfedilinkEnglisharrow-up3·5 个月前Yeah 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 truthyand 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