Skip to content

Commit 535cb79

Browse files
vanillajonathanljharb
authored andcommitted
[guide] Mention both num++ and num ++
1 parent 5568467 commit 535cb79

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,15 +1547,15 @@ Other Style Guides
15471547
<a name="variables--unary-increment-decrement"></a><a name="13.6"></a>
15481548
- [13.6](#variables--unary-increment-decrement) Avoid using unary increments and decrements (++, --). eslint [`no-plusplus`](http://eslint.org/docs/rules/no-plusplus)
15491549
1550-
> 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.
1550+
> 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++` or `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.
15511551
15521552
```javascript
15531553
// bad
15541554

15551555
let array = [1, 2, 3];
15561556
let num = 1;
1557-
num ++;
1558-
-- num;
1557+
num++;
1558+
--num;
15591559

15601560
let sum = 0;
15611561
let truthyCount = 0;

0 commit comments

Comments
 (0)