Dos and don’ts in JavaScript

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, 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.

tags: , , , , , , , , , ,

Get the O’Reilly Programming Newsletter

Weekly insight from industry insiders. Plus exclusive content and offers.