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