mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-29 14:36:22 +00:00
20 lines
316 B
Markdown
20 lines
316 B
Markdown
---
|
|
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);
|
|
}
|
|
```
|