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 - JavaScript Tutorial
From the course: JavaScript: Best Practices for Code Formatting
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Indent consistently5m 54s
-
(Locked)
Space before and after operators3m 23s
-
(Locked)
Use a consistent format for blocks3m 58s
-
(Locked)
Include a space after keywords and arrows3m 2s
-
(Locked)
Use consistent spacing before function signature parentheses3m 37s
-
(Locked)
Break up and indent long-method chains2m 46s
-
(Locked)
Space consistently within enclosing characters7m 58s
-
(Locked)
Space after commas, but not before2m 14s
-
(Locked)
Limit blank space to one line2m 50s
-
(Locked)
Challenge: Optimize spacing30s
-
(Locked)
Solution: Optimize spacing10m 29s
-
(Locked)
-