Skip to content

Commit

Permalink
Add prefer_extracted_top_level_constant analyzer comment to javascrip…
Browse files Browse the repository at this point in the history
…t resistor color duo (exercism/javascript-analyzer#127)
  • Loading branch information
Steffe-Dev committed Feb 20, 2025
1 parent 8b47b7a commit 52b4a06
Showing 1 changed file with 15 additions and 0 deletions.
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.

0 comments on commit 52b4a06

Please sign in to comment.