this post was submitted on 02 Mar 2025
77 points (93.3% liked)

Programmer Humor

21705 readers
249 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

Someone had to do this before the riots started.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 6 points 2 weeks ago (7 children)

Now find the missing semicolon I won't tell you where it should be.

[–] [email protected] 5 points 2 weeks ago (6 children)

Do people not read compiler errors or something? Finding missing semicolons is easy.

[–] [email protected] 3 points 2 weeks ago (1 children)

Ah, but you see, JavaScript is not so straightforward. It tries to help you by automatically inserting missing semicolons, but the approach that it uses is that it will insert them in the first place where doing so would make the code parse. This, unfortunately, means that semicolons are often inserted in places where you were not expecting them, so the advice is to always include them manually yourself so that you are never unpleasantly surprised.

[–] [email protected] 2 points 2 weeks ago

This, unfortunately, means that semicolons are often inserted in places where you were not expecting them

example:

()=>{
  return {k:"v"}; // returns the object
}
()=>{
  return      // returns undefined 
    {k:"v"};  // unreachable 
}

so the advice is to always include them manually yourself so that you are never unpleasantly surprised.

The example will be unpleasantly surprising, no matter where you put semicolons.

load more comments (4 replies)
load more comments (4 replies)