Skip to content

Commit 2a28b9c

Browse files
move #variables--unary-increment-decrement to correct section
1 parent 7da28d4 commit 2a28b9c

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

README.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,35 +1285,6 @@ Other Style Guides
12851285
}
12861286
```
12871287
1288-
- [13.5](#variables--unary-increment-decrement) Avoid using unary increments and decrements (++, --). eslint [`no-plusplus`](http://eslint.org/docs/rules/no-plusplus)
1289-
1290-
> Why? Per the eslint documentation, unary increment and decrement statements are subject to automatic semicolon insertion and can cause silent errors with incrementing or decrementing values within an application. It is also more expressive to mutate your values with statements like `num += 1` instead of `num ++`. Disallowing unary increment and decrement statements also prevents you from pre-incrementing/pre-decrementing values unintentionally which can also cause unexpected behavior in your programs.
1291-
1292-
```javascript
1293-
// bad
1294-
1295-
let array = [1, 2, 3];
1296-
let num = 1;
1297-
let increment = num ++;
1298-
let decrement = -- num;
1299-
1300-
for(let i = 0; i < array.length; i++){
1301-
let value = array[i];
1302-
++value;
1303-
}
1304-
1305-
// good
1306-
1307-
let array = [1, 2, 3];
1308-
let num = 1;
1309-
let increment = num += 1;
1310-
let decrement = num -= 1;
1311-
1312-
array.forEach((value) => {
1313-
value += 1;
1314-
});
1315-
```
1316-
13171288
**[⬆ back to top](#table-of-contents)**
13181289
13191290
@@ -1487,6 +1458,36 @@ Other Style Guides
14871458
// the same applies for `const`
14881459
```
14891460
1461+
<a name="variables--unary-increment-decrement"></a><a name="13.6"></a>
1462+
- [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (++, --). eslint [`no-plusplus`](http://eslint.org/docs/rules/no-plusplus)
1463+
1464+
> Why? Per the eslint documentation, unary increment and decrement statements are subject to automatic semicolon insertion and can cause silent errors with incrementing or decrementing values within an application. It is also more expressive to mutate your values with statements like `num += 1` instead of `num ++`. Disallowing unary increment and decrement statements also prevents you from pre-incrementing/pre-decrementing values unintentionally which can also cause unexpected behavior in your programs.
1465+
1466+
```javascript
1467+
// bad
1468+
1469+
let array = [1, 2, 3];
1470+
let num = 1;
1471+
let increment = num ++;
1472+
let decrement = -- num;
1473+
1474+
for(let i = 0; i < array.length; i++){
1475+
let value = array[i];
1476+
++value;
1477+
}
1478+
1479+
// good
1480+
1481+
let array = [1, 2, 3];
1482+
let num = 1;
1483+
let increment = num += 1;
1484+
let decrement = num -= 1;
1485+
1486+
array.forEach((value) => {
1487+
value += 1;
1488+
});
1489+
```
1490+
14901491
**[⬆ back to top](#table-of-contents)**
14911492
14921493

0 commit comments

Comments
 (0)