You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [2.3](#references--let-require) Use `let` for `require()` imports in NodeJS.
532
-
533
-
> Why? Modules are rather dynamic in nature. If you want to add functionality dynamically later on, it's easier if the module isn't imported as `const`. Also, in some cases `let` is faster than `const` when used on `require()` ([Source](https://stackoverflow.com/a/42767905/7575111)).
- [3.6](#objects--quoted-props) Only quote properties that are invalid identifiers. eslint: [`quote-props`](https://eslint.org/docs/rules/quote-props.html)
675
659
676
660
> Why? In general it is subjectively easier to read. It improves syntax highlighting, and is also more easily optimized by many JS engines.
@@ -691,7 +675,7 @@ $ `npm i` - and you're ready to go!
- [3.7](#objects--prototype-builtins) Do not call `Object.prototype` methods directly, such as `hasOwnProperty`, `propertyIsEnumerable`, and `isPrototypeOf`. eslint: [`no-prototype-builtins`](https://eslint.org/docs/rules/no-prototype-builtins)
696
680
697
681
> Why? These methods may be shadowed by properties on the object in question - consider `{ hasOwnProperty: false }` - or, the object may be a null object (`Object.create(null)`).
@@ -708,7 +692,7 @@ $ `npm i` - and you're ready to go!
- [3.8](#objects--rest-spread) Prefer the object spread operator over [`Object.assign`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) to shallow-copy objects. Use the object rest operator to get a new object with certain properties omitted.
713
697
714
698
```javascript
@@ -787,7 +771,7 @@ $ `npm i` - and you're ready to go!
- [4.5](#arrays--from-array-like) Use [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) for converting an array-like object to an array.
792
776
793
777
```javascript
@@ -800,7 +784,7 @@ $ `npm i` - and you're ready to go!
800
784
const arr = Array.from(arrLike);
801
785
```
802
786
803
-
<a name="arrays--mapping"></a>
787
+
<a name="arrays--mapping"></a><a name="4.6"></a>
804
788
- [4.6](#arrays--mapping) Use [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) instead of spread `...` for mapping over iterables, because it avoids creating an intermediate array.
805
789
806
790
```javascript
@@ -811,7 +795,7 @@ $ `npm i` - and you're ready to go!
- [4.7](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](https://eslint.org/docs/rules/array-callback-return)
816
800
817
801
```javascript
@@ -850,7 +834,7 @@ $ `npm i` - and you're ready to go!
- [8.6](#whitespace--implicit-arrow-linebreak) Enforce the location of arrow function bodies with implicit returns. eslint: [`implicit-arrow-linebreak`](https://eslint.org/docs/rules/implicit-arrow-linebreak)
1554
1538
1555
1539
```javascript
@@ -1846,7 +1830,7 @@ $ `npm i` - and you're ready to go!
> Why? Including extensions inhibits refactoring, and inappropriately hardcodes implementation details of the module you're importing in every consumer.
@@ -2535,7 +2519,7 @@ $ `npm i` - and you're ready to go!
- [15.8](#comparison--no-mixed-operators) When mixing operators, enclose them in parentheses. The only exception is the standard arithmetic operators (`+`, `-`, `*`, & `/`) since their precedence is broadly understood. eslint: [`no-mixed-operators`](https://eslint.org/docs/rules/no-mixed-operators.html)
2540
2524
2541
2525
> Why? This improves readability and clarifies the developer’s intention.
@@ -2764,17 +2748,17 @@ $ `npm i` - and you're ready to go!
- [18.1](#comments--language) Stick to the english language. Always write variable names, function names, comments and co in english.
2769
2753
2770
2754
> Why? Some reasons:
2771
2755
> - Consistency.
2772
2756
> - English is a global language. What if you're part of a german developer team, write code in german and then want to hire someone from another country?
2773
2757
> - JavaScript's keywords are english.
2774
2758
> - Some languages use symbols from different charsets (ö, ä, ü, ß, Ѱ, Ω, etc. pp.). Some of them are illegal as variable/function names and others could break your encoding.
- [18.2](#comments--singleline) Use `//` for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless it’s on the first line of a block.
- [18.3](#comments--singleline) Use `//` for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment unless it’s on the first line of a block.
2808
2792
2809
2793
```javascript
2810
2794
// bad
@@ -2842,8 +2826,8 @@ $ `npm i` - and you're ready to go!
- [18.3](#comments--spaces) Start all comments with a space to make it easier to read. eslint: [`spaced-comment`](https://eslint.org/docs/rules/spaced-comment)
- [18.4](#comments--spaces) Start all comments with a space to make it easier to read. eslint: [`spaced-comment`](https://eslint.org/docs/rules/spaced-comment)
2847
2831
2848
2832
```javascript
2849
2833
// bad
@@ -2879,11 +2863,11 @@ $ `npm i` - and you're ready to go!
- [18.4](#comments--actionitems) Prefixing your comments with`FIXME` or `TODO` (action-items) helps other developers quickly understand if you're pointing out a problem that needs to be revisited, or if you're suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable. The actions are `FIXME: -- need to figure this out` or `TODO: -- need to implement`.
- [18.5](#comments--actionitems) Prefixing your comments with`FIXME` or `TODO` (action-items) helps other developers quickly understand if you're pointing out a problem that needs to be revisited, or if you're suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable. The actions are `FIXME: -- need to figure this out` or `TODO: -- need to implement`.
2884
2868
2885
-
<a name="comments--fixme"></a><a name="18.5"></a>
2886
-
- [18.5](#comments--fixme) Use `// FIXME:` to annotate problems.
2869
+
<a name="comments--fixme"></a><a name="18.6"></a>
2870
+
- [18.6](#comments--fixme) Use `// FIXME:` to annotate problems.
2887
2871
2888
2872
```javascript
2889
2873
class Calculator extends Abacus {
@@ -2896,8 +2880,8 @@ $ `npm i` - and you're ready to go!
2896
2880
}
2897
2881
```
2898
2882
2899
-
<a name="comments--todo"></a><a name="18.6"></a>
2900
-
- [18.6](#comments--todo) Use `// TODO:` to annotate solutions to problems.
2883
+
<a name="comments--todo"></a><a name="18.7"></a>
2884
+
- [18.7](#comments--todo) Use `// TODO:` to annotate solutions to problems.
0 commit comments