This repository was archived by the owner on Aug 9, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 14
14
1 . [ Functions] ( #functions )
15
15
1 . [ Properties] ( #properties )
16
16
1 . [ Variables] ( #variables )
17
+ 1 . [ Constants] ( #constants )
17
18
1 . [ Hoisting] ( #hoisting )
18
19
1 . [ Comparison Operators & Equality] ( #comparison-operators--equality )
19
20
1 . [ Blocks] ( #blocks )
367
368
var superPower = new SuperPower ();
368
369
` ` `
369
370
370
- - Use single ` var ` declaration for multiple variables.
371
+ - Use a single ` var ` declaration for multiple variables.
371
372
Having one ` var ` declaration per variable is an unnecessary code repetition
372
373
and it should hardly ever be a problem anyway as you always want to strive
373
374
at simple functions with as few local variables as possible. If you need
479
480
**[⬆ back to top](#table-of-contents)**
480
481
481
482
483
+ ## Constants
484
+
485
+ - JavaScript doesn't support a notion of constants so we resort to normal
486
+ class variables in their absence. So to denote a variable is meant to be
487
+ treated like a constant you should use the ALL_CAPS notation, e.g.:
488
+
489
+ ` ` `
490
+ WHICH .MyClass .MY_CONSTANT = ' fooBar' ;
491
+ ` ` `
492
+
493
+ Please note, it is still possible to assign a different value to this kind
494
+ of variables so they should only be used as read-only properties. If you
495
+ need to change their values, use a standard variables notation.
496
+
497
+ **[⬆ back to top](#table-of-contents)**
498
+
499
+
482
500
## Hoisting
483
501
484
502
- Variable declarations get hoisted to the top of their scope, but their assignment does not.
You can’t perform that action at this time.
0 commit comments