O
25
c/coding-for-beginnersjulia_leejulia_lee2mo agoMost Upvoted

Warning: I spent 6 hours debugging a single missing semicolon in JavaScript

It took me that long to find it because I was looking at the wrong part of the code, and now I triple check every line before I run anything.
3 comments

Log in to join the discussion

Log In
3 Comments
gavina73
gavina732mo ago
Used to be all smug about semicolons being optional in JS. Then I spent 45 minutes chasing a bug that only showed up in Safari and suddenly I'm a semicolon truther.
1
milesj70
milesj701mo ago
Oh man, been there. I started putting semicolons at the end of every line that doesn't end with a curly brace just to be safe. It's one of those things where you learn the hard way that "optional" really means "optional until it isn't
8
oscar_ellis
The prettier plugin saved my sanity on this exact thing. Just set it up to auto-add semicolons on save (took like 2 minutes) and I never think about it anymore. Safari specifically is the worst about line break parsing, especially when you have something like a return statement with a newline. Honestly, I'd rather let the tool handle it than have another 45 minute debugging session.
6