Useful Javascript snippets

Async Loop

for (let item of items) {
  await doSomethingWith(item)
}

For of with index

for (const [i, v] of ['a', 'b', 'c'].entries()) {
  console.log(i, v)
}