mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 05:58:04 -05:00
20
README.md
20
README.md
@@ -1521,24 +1521,28 @@ Other Style Guides
|
||||
|
||||
let array = [1, 2, 3];
|
||||
let num = 1;
|
||||
let increment = num ++;
|
||||
let decrement = -- num;
|
||||
num ++;
|
||||
-- num;
|
||||
|
||||
let sum = 0;
|
||||
let truthyCount = 0;
|
||||
for(let i = 0; i < array.length; i++){
|
||||
let value = array[i];
|
||||
++value;
|
||||
sum += value;
|
||||
if (value) {
|
||||
truthyCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// good
|
||||
|
||||
let array = [1, 2, 3];
|
||||
let num = 1;
|
||||
let increment = num += 1;
|
||||
let decrement = num -= 1;
|
||||
num += 1;
|
||||
num -= 1;
|
||||
|
||||
array.forEach((value) => {
|
||||
value += 1;
|
||||
});
|
||||
const sum = array.reduce((a, b) => a + b, 0);
|
||||
const truthyCount = array.filter(Boolean).length;
|
||||
```
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
Reference in New Issue
Block a user