r/ProgrammerHumor • • Jul 10 '18

What people think coding is...

Post image
21.1k Upvotes

398 comments sorted by

View all comments

144

u/[deleted] Jul 10 '18

Whats up with all the front-end stufd, the missing ; which makes someone not sleep for 4 days and praising the achievement of being able to compile your code?

4

u/[deleted] Jul 10 '18

Just started messing with Javascript. Why do some lines need trailing semicolons and some lines don’t?

10

u/Jetbooster Jul 10 '18

Es6+ JavaScript don't give a shit. No lines need semicolons (at the end). Almost every style guide or linter will enforce it though.

What you maybe are seeing is some lines are utilising promises, or some other chained function:

functionCall()
  .then(...)

If you were to put a semicolon in here it would break, because the .then() is dangling. It's technically a one liner over two lines.