F
22

Spent 4 hours debugging a missing semicolon in JavaScript

I was following a tutorial on making a simple to-do list app, and my code just wouldn't run. Console kept yelling 'unexpected token' at me lol. Checked everything like 3 times, then my buddy looked over my shoulder and pointed out I forgot a semicolon on line 12. Felt so dumb but also learned why people say to use a linter. Has anyone else wasted a ton of time on a tiny typo like that?
3 comments

Log in to join the discussion

Log In
3 Comments
the_rowan
the_rowan1mo ago
I read a blog post that said most debugging time goes to dumb little mistakes like that.
6
shanef34
shanef341mo ago
Man, I read something just last week about how JavaScript's automatic semicolon insertion can actually cause more bugs than it fixes... it's a weird quirk of the language for sure. A linter would have caught that in seconds, but I've also heard that some of them flag stuff that's totally fine, so I get why people are mixed on them. Probably the best lesson is just to build the habit of putting the semicolons in yourself and not rely on the engine to figure it out.
6
gavin469
gavin4691mo ago
Missing semicolons are annoying for sure but honestly, spending 4 hours on one feels like a rite of passage. A linter would have caught it in 2 seconds though. I get why people swear by them, but I've seen linters flag so many false positives that I don't trust them either. Sometimes you just need to eyeball it or have a fresh pair of eyes look at your code. The real lesson here is that JavaScript's automatic semicolon insertion is not as automatic as people think. Better to just get in the habit of typing them yourself and move on.
2