☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 7 months agoThe Divine Trinity of JavaScriptlemmy.mlimagemessage-square11fedilinkarrow-up1188
arrow-up1188imageThe Divine Trinity of JavaScriptlemmy.ml☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 7 months agomessage-square11fedilink
minus-squarexmunk@sh.itjust.workslinkfedilinkarrow-up15·7 months ago== Well there’s your problem, you’re using an operator that shouldn’t exist. Triple equals all the things and if you want to coerce types write it out explicitly.
minus-squaremogoh@lemmy.mllinkfedilinkarrow-up17·7 months agoWhile you are basically right, the problem is that there is an operator that should not exist. Though that is not the biggest problem of JavaScript.
minus-squaredeadbeef79000@lemmy.nzlinkfedilinkarrow-up3·7 months agoSurprise Type coercion is our greatest weapon! What about the limitless coffers of Rome implicit global scope? Well then, surprise type coercion and the limitless coffers of Rome implicit global scope are our greatest weapons.
minus-squareZagorath@aussie.zonelinkfedilinkarrow-up6·7 months ago== is acceptable for null checks. And basically nothing else.
minus-squareshrugal@lemm.eelinkfedilinkarrow-up2·7 months agoIt should probably be replaced with a more bespoke operator for that, like x isempty or something.
minus-squareJustas🇱🇹@sh.itjust.workslinkfedilinkarrow-up2·7 months ago["a"] + ["b"] = "ab" Goodnight, everyone.
Well there’s your problem, you’re using an operator that shouldn’t exist. Triple equals all the things and if you want to coerce types write it out explicitly.
While you are basically right, the problem is that there is an operator that should not exist. Though that is not the biggest problem of JavaScript.
SurpriseType coercion is our greatest weapon!What about the
limitless coffers of Romeimplicit global scope?Well then,
surprisetype coercion andthe limitless coffers of Romeimplicit global scope are our greatest weapons.== is acceptable for null checks. And basically nothing else.
It should probably be replaced with a more bespoke operator for that, like
x isempty
or something.The
??
operator?["a"] + ["b"] = "ab"
Goodnight, everyone.