Chapter 20

Ten Common JavaScript Bugs and How to Avoid Them

In This Chapter

arrow Catching mismatched brackets

arrow Steering clear of incorrect punctuation

arrow Fixing errors

arrow Adjusting bad variable names

“Have no fear of perfection — you’ll never reach it.”

— Salvador Dali

Even the best JavaScript programmers make mistakes. Sometimes, these mistakes cause your program to not produce the results that you wanted, and sometimes they cause the program to not run at all. Any problem that causes a program not to run or not to run as expected is called a bug. Throughout this book, we give you tips and tools for finding and correcting bugs as they come up.

Part of becoming a better programmer is to be able to identify potential sources of bugs and stomp them out faster and earlier. Eventually, you’ll start noticing that you make fewer and fewer mistakes and that beautiful bug-free code flows from your fingertips on a regular basis. When this happens, you’re well on your way to becoming a JavaScript ninja.

In this chapter, we point out ten common mistakes that JavaScript programmers at all levels ...

Get Coding with JavaScript For Dummies now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.