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.

Include leading spaces in comments

Include leading spaces in comments - JavaScript Tutorial

From the course: JavaScript: Best Practices for Code Formatting

Start my 1-month free trial

Include leading spaces in comments

- [Instructor] Spaces are optional in comments, but you can include them to increase the legibility of your comments. In particular, it's a common practice to include a space between the starting comment characters and the commented code. I can already see that in the format for my start block. I'm going to add a single line comment before my variable just to mark this as a section that contains variables. So I'll add a blank line to keep some space from U strict, and then I can just do a single line, slash slash, and variables. Now at a glance, it takes a little work to see where the slashes end and the word variables begins. But if I click in here and stick a space after the second slash, it immediately becomes easier to recognize that as a comment containing the word variables. ESLint contains a spaced comment rule that let's me specify whether comments should include spaces. The documentation makes it clear that you…

Contents