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.
Use consistent spacing before function signature parentheses - JavaScript Tutorial
From the course: JavaScript: Best Practices for Code Formatting
Use consistent spacing before function signature parentheses
- JavaScript has a number of syntaxes for creating a function signature, including function declarations, function expressions, anonymous functions, async functions and arrow functions. As a result, standardizing the way you create functions in your code can be a challenge. Different developers approach spacing in function signatures, differently. One common approach, is to include a space before the parens in an anonymous function signature, but not in a named function signature. This style makes it straightforward to add or remove a name, without needing to adjust spacing. Other developers prefer to standardize on spaces before parens, in all function signatures. The extra spaces added by the style can make the code easier to read. Finally, some developers never include spaces before parens in function signatures, preferring to treat the combination of keyword, or name or arrow symbol, and parens as a single unit.…
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)
-