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 ...
Get Async JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.