DEV Community

Cover image for Oops, I did it again: A guide to debugging common JavaScript errors

Oops, I did it again: A guide to debugging common JavaScript errors

Ali Spittel on March 25, 2019

Writing JavaScript code can sometimes make us feel like running, hiding, or just being scared. But, with some debugging tips we can get in the zone...
Collapse
 
emmabostian profile image
Emma Bostian ✨

I literally don't have words

Collapse
 
zeddotes profile image
zeddotes

Cannot read property 'words' of undefined.

Collapse
 
kevinhq profile image
kevin

lol

Collapse
 
jochemstoel profile image
Jochem Stoel
function oneMoreTime(stillBelieve=true, loneliness=0) {
    if (!stillBelieve && loneliness < 0) return
    loneliness++
    return oneMoreTime(stillBelieve, loneliness)
}

This is poetry.

Collapse
 
gypsydave5 profile image
David Wickes

First, if you're in an infinite loop, quit the tab if you're in Chrome or Edge, and quit the browser window in FireFox.

FireFox is a lot friendlier than this - you don't need to close the whole browser and you get a nice, friendly message:

too much recursion indeed!

Collapse
 
andy profile image
Andy Zhao (he/him)

Big fan of the Bracket Pair Colorizer extension! Before, I didn't know that something wasn't right, and it definitely gives you a sign!

Collapse
 
daveskull81 profile image
dAVE Inden

I didn’t know about this extension. I’m totally going to try it out. It seems like it would save me a bunch of time.

Collapse
 
laurieontech profile image
Laurie

So now the question is which of the referenced songs am I listening to first...

I've always been partial to Everytime :)

Collapse
 
gabrielecimato profile image
Gabriele Cimato

Ahah brilliant!

Collapse
 
annarankin profile image
Anna Rankin

Nice one Ali! We recently started using Prettier on one of our projects and I love it - it catches silly mistakes and quells syntax debates 🤘 thanks as always!

Collapse
 
noor_codes profile image
Noorullah Ahmadzai

const Ali = {
Name: 'Ali',
LovesBritney: true,
ShoutOut: function(){
console.log('Ali is awesome');
}

Ali.ShoutOut();

😅

Collapse
 
noor_codes profile image
Noorullah Ahmadzai

Loved the way you explained the full stack issue, the rest I had a basic info about!
Still learnt something new 😃

Collapse
 
tuxrafa profile image
Rafael Oliveira

It's wonderful!!!
Sometimes these errors makes anyone Crazy, but Everytime I got these errors, I'll remember this text.

Collapse
 
davinaleong profile image
Davina Leong • Edited

#britneyspears

Sorry, just can't help myself when I saw the title...

Collapse
 
mebble profile image
Neil Syiemlieh

Read this last night and "Lucky" was stuck in my head all day today

Collapse
 
celsodesa profile image
Celso de Sá

Using StandardJS?

Collapse
 
tryped_ profile image
Colin Domansky

Wow!

Collapse
 
daveskull81 profile image
dAVE Inden

This post is great! Ali has tons of info here with links to other resources too. This is a great resource for learning about why some of these really common errors happen. Nice work!

Collapse
 
moremooredesign profile image
Jeremy Moore

I need to write a post on a great follow up to this: debugging closures. I'm reminded of a big blocker I encountered when trying to debug an inner function one time.

Collapse
 
jsrodrigues89 profile image
Juliano Rodrigues

Really good article! Thanks