Updated guidance on anonymous functions

This commit is contained in:
Andrew Henry 2020-05-16 16:11:42 -07:00 committed by GitHub
parent 41dc9c794d
commit a40ff07353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -144,9 +144,9 @@ JavaScript sources in Open MCT should:
letters, with underscores between words (e.g. SOME_CONSTANT). They should always be declared as `const`s letters, with underscores between words (e.g. SOME_CONSTANT). They should always be declared as `const`s
1. File names should be the name of the exported class, plus a .js extension 1. File names should be the name of the exported class, plus a .js extension
(e.g. SomeClassName.js). (e.g. SomeClassName.js).
1. Avoid anonymous functions, except when functions are short (a few lines) 1. Avoid anonymous functions, except when functions are short (one or two lines)
and/or their inclusion makes sense within the flow of the code and their inclusion makes sense within the flow of the code
(e.g. as arguments to a forEach call). (e.g. as arguments to a forEach call). Anonymous functions should always be arrow functions.
1. Named functions are preferred over functions assigned to variables. 1. Named functions are preferred over functions assigned to variables.
eg. eg.
```JavaScript ```JavaScript