☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 8 months agoThe Divine Trinity of JavaScriptlemmy.mlimagemessage-square10fedilinkarrow-up1185arrow-down17
arrow-up1178arrow-down1imageThe Divine Trinity of JavaScriptlemmy.ml☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 8 months agomessage-square10fedilink
minus-squarexmunk@sh.itjust.workslinkfedilinkarrow-up15arrow-down3·8 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-up16·8 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·8 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·8 months ago== is acceptable for null checks. And basically nothing else.
minus-squareshrugal@lemm.eelinkfedilinkarrow-up2·8 months agoIt should probably be replaced with a more bespoke operator for that, like x isempty or something.
minus-squareJustas🇱🇹@sh.itjust.workslinkfedilinkarrow-up1·8 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.