You need to know, this example is wrong

it's not work

1,2,3,4 will be output at the same time.

const waitFor = (ms) => new Promise((r) => setTimeout(r, ms));

const start = async () => {

await array.forEach(async function (element) {

await waitFor(1000);









Develop with pleasure!

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alan He

Alan He

Develop with pleasure!

More from Medium

Foods That Taste Better in the South

3 Steps to Tell Better Jokes

Take 5! —5.02.2022

Internet of Things: How it Helps Micro-Mobility Sector in Overcoming the Challenges

Micro-Mobility Sector