From the course: JavaScript: Best Practices for Code Formatting

Unlock the full course today

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

Space consistently within enclosing characters

Space consistently within enclosing characters - JavaScript Tutorial

From the course: JavaScript: Best Practices for Code Formatting

Start my 1-month free trial

Space consistently within enclosing characters

- [Instructor] There's a wide variety of approaches to spacing after an opening paren bracket or brace, and before the corresponding closing character. Developers who pad some or all of these enclosing characters with spaces may feel that the spaces make the enclosed values easier to read. On the other hand, the choice to omit the spaces has the advantage of creating a clear association between values and the enclosing characters which generally indicate what type of data is enclosed. Many style guides specify an approach to spacing within enclosing characters. So if your project or organization has a style guide, that's a great place to start. If you're creating your own style, then you should pick a style for each type of character and use that style consistently. Note that the style doesn't need to be the same among all types of enclosing characters. In fact, popular style guides often set out one or more distinct styles…

Contents