A few best practices for when you’re learning the language
With every programming language, there’s a list of do’s and don’ts and JavaScript is no exception. Some of these best practices are there for your protection (like always always always using semi-colons!), some to make your code more readable and less error-prone, and some to increase the efficiency of your code.
If you search for “best practices JavaScript” you’ll find lots of great information on the topic. You’ll also find a few disagreements (for instance, always use comma separated variable declarations vs. never use comma separated variable declarations). That said, there are some fundamental best practices that can really help you write better code. It worth spending some time to learn a few these as you learn JavaScript. And of course, over time, you’ll even develop a few of your own.
In this installment of Head First JavaScript Programming Teasers, we take a look at a few common best practices that will help make your code more readable, make the best use of the language, and make your code a bit more efficient.
Previous Head First JavaScript Programming Teasers Episodes
- Part 1: A Teaser from Head First JavaScript Programming
- Part 2: Getting JavaScript in your pages, the right way
- Part 3: What makes JavaScript different?
- Part 4: Dive into JavaScript
- Part 5: JavaScript variables and types
- Part 6: Using the console
- Part 7: JavaScript Scope
- Part 8: Working with the DOM
- Part 9: Keeping track of this in your JavaScript code
- Part 10: What it really means when people say “Everything in JavaScript is an object”