JavaScript: Best Practices for Code Formatting
1h 51mIntermediate2019-09-10
Authors

Sasha Vodnik
Principal Technical Course Developer at DocuSign
Course details
JavaScript offers developers tremendous power, but also a wide variety of code style choices. Its evolution over decades and shifts in audience and approach have left communities fragmented and impeded code sharing. In this course, longtime coder and teacher Sasha Vodnik provides a core set of practices for creating code that can be read by more people than its creators. Learn about formatting details like commenting, punctuation, and spacing to maximize your code's ability to travel and thrive.
Learning objectives
Using modern deployment tools
Working with ESLint
Creating easy-to-read comments
Using commas consistently
Standardizing line length in your code
Using a consistent format for blocks
Choosing and implementing a standard indent
Learning objectives
Using modern deployment tools
Working with ESLint
Creating easy-to-read comments
Using commas consistently
Standardizing line length in your code
Using a consistent format for blocks
Choosing and implementing a standard indent
Skills covered
JavaScriptOracleLearningProgramming LanguagesSoftware Development
Concepts
0. Introduction
- 01 - Modern standards for your JavaScript
- 02 - What you should know
- 03 - Set up your environment
1. Why Best Practices
- 04 - Style guides
- 05 - Use modern deployment tools
- 06 - ESLint
- 07 - Foundational practice - Use strict mode
2. Creating Comments
- 08 - Use single-line syntax for single lines
- 09 - Multi-line syntax with leading asterisks
- 10 - Include leading spaces in comments
- 11 - Challenge - Create JavaScript comments
- 12 - Solution - Create JavaScript comments
3. Using Punctuation
- 13 - End statements with a semicolon
- 14 - Don't rely on auto semicolon insertion
- 15 - Standardize line length
- 16 - Use commas consistently
- 17 - Include a comma in a list of values
- 18 - Challenge - Optimize punctuation
- 19 - Solution - Optimize punctuation
4. Using Spacing
- 20 - Indent consistently
- 21 - Space before and after operators
- 22 - Use a consistent format for blocks
- 23 - Include a space after keywords and arrows
- 24 - Use consistent spacing before function signature parentheses
- 25 - Break up and indent long-method chains
- 26 - Space consistently within enclosing characters
- 27 - Space after commas, but not before
- 28 - Limit blank space to one line
- 29 - Challenge - Optimize spacing
- 30 - Solution - Optimize spacing
Conclusion
- 31 - Next steps