Appendix A. JavaScript coding standard

This appendix covers:
  • Exploring why a coding standard is important
  • Laying out and documenting code consistently
  • Naming variables consistently
  • Isolating code using namespaces
  • Organizing files and ensuring consistent syntax
  • Validating code using JSLint
  • Using of a template that embodies the standard

Coding standards are contentious. Almost everyone agrees you should have one, but few seem to agree on what the standard should be. Let’s consider why a coding standard is especially important for JavaScript.

A.1. Why we need a coding standard

Having a well-defined standard for a loosely typed, dynamic language like JavaScript is almost certainly more important than with stricter languages. ...

Get Single Page Web Applications now with O’Reilly online learning.

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