9
Spent 4 hours debugging a missing semicolon in JavaScript
I was working on a simple calculator project last night and it kept breaking at the same point. The console showed nothing helpful, just a blank error. I rewrote entire functions, checked my logic three times, even restarted my computer. Four hours later I noticed I left out a single semicolon in a loop condition. That tiny thing broke everything and I felt like an idiot. Has anyone else lost that much time to a typo that small?
2 comments
Log in to join the discussion
Log In2 Comments
evan_morgan8118d ago
Yeah but a missing semicolon in a loop condition shouldnt totally break everything. That's not how JS works usually. Semicolons are mostly optional in JavaScript, the interpreter adds them automatically with automatic semicolon insertion. If you missed one in a for loop condition like for (i=0 i<10 i++) that would break it. But a regular while or if statement without a semicolon? That wouldn't do anything. You probably had an actual syntax error somewhere else that happened to be near the semicolon. The semicolon was just the first thing you noticed when you finally looked close enough.
2