How to wait in javascript?

Published: 01 January 1970
on channel: GamerMan
54
1

I this video i show you how to make a wait function(because there is no built in one).

Code:

async function waitUntil(conditionFunction, interval = 100) {
while (!conditionFunction()) {
await new Promise(resolve = /**add an angled bracket here**\ setTimeout(resolve, interval));
}
}

async function wait(time) {
await new Promise(resolve = /**add an angled bracket here**\ setTimeout(resolve, time*1000));
}

Chapters:

0:00 - 0:49 - Intro
0:50 - 1:37 - Wait Until
1:38 - 2:07 - Wait
2:08 - 2:24 - Outro


On this page of the site you can watch the video online How to wait in javascript? with a duration of hours minute second in good quality, which was uploaded by the user GamerMan 01 January 1970, share the link with friends and acquaintances, this video has already been watched 54 times on youtube and it was liked by 1 viewers. Enjoy your viewing!