Sjmarf@sh.itjust.works to Programmer Humor@programming.dev · 4 months agoJavaScriptsh.itjust.worksimagemessage-square48fedilinkarrow-up15arrow-down11
arrow-up14arrow-down1imageJavaScriptsh.itjust.worksSjmarf@sh.itjust.works to Programmer Humor@programming.dev · 4 months agomessage-square48fedilink
minus-squareVeganPizza69 Ⓥ@lemmy.worldlinkfedilinkarrow-up2·edit-24 months agoWho would use that kind of type coercion? Who? I want to see his face.
minus-squaremarcos@lemmy.worldlinkfedilinkarrow-up1·4 months agoIt’s not even the coercion that is the problem here. The types are already bad by themselves.
minus-squaredejected_warp_core@lemmy.worldlinkfedilinkarrow-up0·4 months agoI take this as less of a “I can’t use this intuitive feature reliably” thing and more of a “the truth table will bite you in the ass when you least expect it and/or make a mistake” thing.
minus-squareflying_sheep@lemmy.mllinkfedilinkarrow-up2·4 months agoJust use a formatter. It’ll show you that the second one is two statements: {} (the empty block) +[] coerce an empty array to a number: new Number(new Array())
Who would use that kind of type coercion? Who? I want to see his face.
It’s not even the coercion that is the problem here. The types are already bad by themselves.
I take this as less of a “I can’t use this intuitive feature reliably” thing and more of a “the truth table will bite you in the ass when you least expect it and/or make a mistake” thing.
Just use a formatter. It’ll show you that the second one is two statements:
{}
(the empty block)+[]
coerce an empty array to a number:new Number(new Array())