Skip to content

Instantly share code, notes, and snippets.

View Ketcap's full-sized avatar
🏠
Working from home

Uğur Oruç Ketcap

🏠
Working from home
View GitHub Profile
@Ketcap
Ketcap / async-foreach.js
Created December 22, 2018 11:27 — forked from Atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)