tfm@europe.pub to Programmer Humor@programming.devEnglish · 11 days agoTrue crimeeurope.pubimagemessage-square67linkfedilinkarrow-up1166arrow-down19
arrow-up1157arrow-down1imageTrue crimeeurope.pubtfm@europe.pub to Programmer Humor@programming.devEnglish · 11 days agomessage-square67linkfedilink
minus-squareLemminary@lemmy.worldlinkfedilinkarrow-up4·edit-210 days 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-up2·10 days 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.
Common JavaScript L