Skip to content

Commit

Permalink
no-array-for-each: Add more reasoning to the docs (#2183)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamiell authored Aug 17, 2023
1 parent 6191299 commit 6d15a02
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/rules/no-array-for-each.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Benefits of [`for…of` statement](https://developer.mozilla.org/en-US/docs/Web/
- Better readability
- Ability to exit early with `break` or `return`

Additionally, using `for…of` has great benefits if you are using TypeScript, because it does not cause a function boundary to be crossed. This means that type-narrowing earlier on in the current scope will work properly while inside of the loop (without having to re-type-narrow). Furthermore, any mutated variables inside of the loop will picked up on for the purposes of determining if a variable is being used.

## Fail

```js
Expand Down

0 comments on commit 6d15a02

Please sign in to comment.