Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
- const asyncForEach = async (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)
- console.log(num)
- })
- console.log('Done')
- }
- start()
Add Comment
Please, Sign In to add comment