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

Use consistent spacing before function signature parentheses - JavaScript Tutorial

From the course: JavaScript: Best Practices for Code Formatting

Start my 1-month free trial

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.…

Contents