wiki/content/20201030093304-javascript_for_of.md

316 B

id title
88c7d978-30a1-4908-bbd8-3263fb6c1d44 JavaScript For Of

Syntax

const arr = ['a', 'b', 'c'];
for (const elem of arr) {
    console.log(elem);
}
const arr = ["a", "b", "c"];
for (const [index, elem] of arr.entries()) {
  console.log(index + ". " + elem);
}