Avoiding Common Mistakes

Most beginning programmers make simple syntactic mistakes. It takes a long time to stop forgetting to close quotes, curly brackets, and parentheses, but luckily modern browsers have JavaScript bug detectors that detect such errors for you. Those bug detectors will be described later in the chapter. This section covers techniques for avoiding a few common mistakes that many browser bug detectors won't catch.

Use a Consistent Naming Convention

The JavaScript bug detector often misses incorrect capitalization and pluralization of variable and function names, a common and annoying error. You'll greatly reduce the occurrence of such mistakes if you stick to one convention for naming variables and functions. For instance, I name ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.