Formatting practices

The code samples in this book use some of our personal preferences for laying out code. Some of these practices are necessary best practices; others increase readability. If you have different preferences, as long as the code remains correct, that’s absolutely fine; the important thing is to be consistent.

The main reasons for being concerned about formatting are

  • Ensuring syntactically correct JavaScript
  • Ensuring that your code functions correctly when minified
  • Improving readability for yourself and/or others on your team

Start with an easy formatting practice: indentation.

Indenting code

The only real reason to indent your code is to make it considerably easier for mere humans to read. JavaScript interpreters don’t ...

Get Getting MEAN with Mongo, Express, Angular, and Node, Second Edition 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.