---
description: for
---

# loop

```
const list = ['a', 'b', 'c'];

for (let [index, item] of list.entries()) {
    console.log(index, item); // 0 'a', 1 'b', 2 'c'
}
```

善用 Array destructuring 可以讓 for loop 更清楚，Map 也可以用 for loop

```javascript
var findWinners = function(matches) {
    let lookup = new Map()
    for( const [winner, loser] of matches){  }
    for(const [player, lose] of lookup){ }
  
};

findWinners([[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]])
```
