From the course: JavaScript: Best Practices for Code Formatting

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Indent consistently

Indent consistently - JavaScript Tutorial

From the course: JavaScript: Best Practices for Code Formatting

Start my 1-month free trial

Indent consistently

- [Instructor] Although spaces don't change the meaning of your code in Javascript, appropriate use of spaces is important for creating code that's readable by humans. And when it comes to making your code more readable, nothing makes a bigger impact than consistent indents. Whenever the contents of braces, brackets, or parens don't fit in a single line, it's common to start a new line after the opening punctuation, and indent all nested statements. As you build out code, you'll inevitably end up multiple levels deep, with indented statements nested within other indented statements. For this reason, consistently applied indents are key in being able to read the code and understand the relationship between statements. Some developers use spaces for indents while others prefer tabs but common style guides tend to favor spaces. Different developers may also choose a different number of spaces for each level of indent…

Contents