💡
2

Spent 3 hours debugging a missing semicolon in JavaScript last night

I was following along with a tutorial and my whole page just wouldn't load, turns out I forgot one semicolon at the end of a function. Has anyone else had a bug like this that took way too long to find?
4 comments

Log in to join the discussion

Log In
4 Comments
skyler_jackson27
I read somewhere that most coding bugs are actually just simple typos like that.
7
diana617
diana6171mo ago
Right, @skyler_jackson27, isn't it wild how our brains just lie to us like that? I've spent maybe an hour looking at one dumb missing comma before, and it feels so stupid when you finally spot it. Usually I have to step away and come back later, or yeah, just ask someone else to look at it real quick. Even when you know it's probably a basic typo, your eyes will still gloss right over it because you're so sure the code is perfect. It's like your brain is gaslighting you into thinking you wrote it correctly the first time. For real, I bet half of all bugs could be fixed if we just had someone else read our code for five seconds.
2
michael669
michael6691mo ago
Went through the exact same thing last week but with a missing closing parenthesis in a React useEffect. Spent like 45 minutes staring at it before realizing I just forgot to close the bracket. Pretty sure my brain is actively sabotaging me at this point.
6
phoenixw11
phoenixw111mo ago
Honestly that makes me wonder though, how many times did you look at that line and just skip right over the missing semicolon because your brain filled it in automatically? I've done that where I'll stare at a line for twenty minutes and finally have my buddy look at it and they spot it in two seconds. Like, I had a missing closing bracket that crashed an entire React component and I literally rewrote the whole thing from scratch before noticing I just forgot a curly brace. Did you end up catching it yourself or did someone else point it out to you in the end?
5