wiki/content/20201030093304-javascript_for_of.md

22 lines
333 B
Markdown
Raw Normal View History

2024-05-06 20:40:05 +00:00
---
2024-10-29 18:27:12 +00:00
date: 2020-10-30
2024-05-06 20:40:05 +00:00
id: 88c7d978-30a1-4908-bbd8-3263fb6c1d44
title: JavaScript For Of
---
# Syntax
``` javascript
const arr = ['a', 'b', 'c'];
for (const elem of arr) {
console.log(elem);
}
```
``` javascript
const arr = ["a", "b", "c"];
for (const [index, elem] of arr.entries()) {
console.log(index + ". " + elem);
}
```