forked from exercism/website-copy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prefer_extracted_top_level_constant analyzer comment to javascrip…
…t resistor color duo (exercism/javascript-analyzer#127)
- Loading branch information
1 parent
8b47b7a
commit 52b4a06
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...r-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# prefer extracted top level constant | ||
|
||
Consider extracting the constant to the top level scope: | ||
|
||
```javascript | ||
const %{name} = %{value} | ||
|
||
// the rest of your code below it | ||
export const decodedValue = (...) | ||
``` | ||
|
||
Only functions, classes and constants that are `export`ed, are visible and | ||
accessible from the outside. These constants can live in the same | ||
file without being exposed to other code. Also, extracting constants saves memory | ||
by avoiding repeated allocations in functions when those same constants are reused. |