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.
Standardize line length - JavaScript Tutorial
From the course: JavaScript: Best Practices for Code Formatting
Standardize line length
- [Instructor] Aside from automatic semicolon insertion, white space is not significant in JavaScript. As a result, you can theoretically write lines of code of any length. And indeed one of the ways that Minification reduces character count is by reducing code to a single line. However, when formatting code for human usability, limiting line length is a widely adopted practice. Shorter lines enable you to fully view each line without wrapping or scrolling. In addition, breaking up a long statement across multiple lines when combined with indentation, can help you parse what the entire statement is doing as well as any steps involved in the process. Code is generally displayed in a fixed width font, meaning that each character takes up the same amount of space on the line. For this reason it's common to measure line lengths in characters. Common line lengths include 80 or 100 characters. In my app.js file, a few lines look…
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)
End statements with a semicolon5m 10s
-
(Locked)
Don't rely on auto semicolon insertion4m 19s
-
(Locked)
Standardize line length6m 33s
-
(Locked)
Use commas consistently3m 38s
-
(Locked)
Include a comma in a list of values3m 21s
-
(Locked)
Challenge: Optimize punctuation31s
-
(Locked)
Solution: Optimize punctuation5m 23s
-
(Locked)
-
-