how to make code wait for 2 seconds js code example
Example 1: javascript wait 10 seconds
setTimeout(function () {
// ...
}, 10000);
// or
.then(() => {
// ...
({ timeout: 10000 });
});
Example 2: How do you wait for 5 seconds in JavaScript?
timeout(ms) { //pass a time in milliseconds to this function
return new Promise(resolve => setTimeout(resolve, ms));
}