14
Spent three hours yesterday because I forgot a single semicolon
I was writing a simple function in JavaScript to add two numbers together. Everything looked right, but the console kept throwing an 'unexpected token' error. I checked my brackets, my variable names, everything. I finally found it after scrolling line by line for way too long. I'd missed the semicolon at the end of the line where I declared the function. Anyone have a good trick for catching these tiny syntax mistakes faster?
3 comments
Log in to join the discussion
Log In3 Comments
grant.felix2d ago
Honestly I just use a linter for that stuff. It catches missing semicolons right away so I don't waste time.
2
wesley1812d ago
Totally agree, a linter saves so much headache. I used to spend ages hunting for tiny syntax errors. Now my editor just highlights them instantly.
1
spencer82d ago
My buddy at work refused to use a linter for the longest time, @wesley181. He spent a whole afternoon once trying to figure out why his script wouldn't run, and it was just a single misplaced comma. After that he finally set one up, and now he says it's like having a second pair of eyes that never get tired. It really does save you from those tiny mistakes that eat up your time. Watching him struggle was all the proof I needed.
6