tfm@europe.pub to Programmer Humor@programming.devEnglish · 3 months agoTrue crimeeurope.pubexternal-linkmessage-square50fedilinkarrow-up1168arrow-down19
arrow-up1159arrow-down1external-linkTrue crimeeurope.pubtfm@europe.pub to Programmer Humor@programming.devEnglish · 3 months agomessage-square50fedilink
minus-squareLemminary@lemmy.worldlinkfedilinkarrow-up3·edit-23 months ago Explanation for nerds The reason is the JS compiler removes whitespace and introduces semicolons only “where necessary”. So writing function myFn() { return true; } Is not the same as function myFn() { return true; } Because the compiler will see that and make it: function myFn() { return; true; } You big ol’ nerd. Tee-hee.
minus-squareEphera@lemmy.mllinkfedilinkEnglisharrow-up1·3 months agoThat’s terrifying, especially in JS where no type system will fuck you up for returning nothing when you should’ve returned a boolean.
Explanation for nerds
The reason is the JS compiler removes whitespace and introduces semicolons only “where necessary”.
So writing
Is not the same as
Because the compiler will see that and make it:
You big ol’ nerd. Tee-hee.
That’s terrifying, especially in JS where no type system will fuck you up for returning nothing when you should’ve returned a boolean.