Skip to Content
Speaking JavaScript
book

Speaking JavaScript

by Axel Rauschmayer
February 2014
Beginner to intermediate content levelBeginner to intermediate
460 pages
8h 32m
English
O'Reilly Media, Inc.
Content preview from Speaking JavaScript

Chapter 26. A Meta Code Style Guide

JavaScript has many great style guides. Thus, there is no need to write yet another one. Instead, this chapter describes meta style rules and surveys existing style guides and established best practices. It also mentions practices I like that are more controversial. The idea is to complement existing style guides rather than to replace them.

Existing Style Guides

These are style guides that I like:

Additionally, there are two style guides that go meta:

General Tips

This section will cover some general code writing tips.

Code Should Be Consistent

There are two important rules for writing consistent code. The first rule is that, if you start a new project, you should come up with a style, document it, and follow it everywhere. The larger the team, the more important it is to check for adherence to the style automatically, via tools such as JSHint. When it comes to style, there are many decisions to make. Most of them have generally agreed-upon answers. Others have to be defined per project. For example:

  • How much whitespace (after parentheses, between statements, etc.)
  • Indentation ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Joy of JavaScript

The Joy of JavaScript

Luis Atencio
Secrets of the JavaScript Ninja, Second Edition

Secrets of the JavaScript Ninja, Second Edition

Bear Bibeault, Josip Maras, John Resig

Publisher Resources

ISBN: 9781449365028Errata