O'Reilly logo

Async JavaScript by Trevor Burnham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Code Style in This Book

JavaScript has no official style guide, but maintaining a consistent style within a project is important. For this book, I’ve adopted the following (very common) conventions:

  • Two-space indentation

  • camelCase identifiers

  • Semicolons at the end of every expression, except function definitions

More esoterically, I’ve adopted a special convention for indentation in a chain of function calls, based on a proposal by Reg Braithwaite. The rule is, essentially, that two function calls in a chain have the same indentation level if and only if they return the same object. So, for instance, I might write the following:

 
$(​'#container > ul li.inactive'​)
 
.slideUp();

jQuery’s slideUp method returns the same object that it ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required