wait javascript
function sleep(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
console.log("Hello");
sleep(2000);
console.log("World!");//code before the pause
setTimeout(function(){
//do what you need here
}, 2000);function pause(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
//Pause for 1000 milliseconds
pause(1000) wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}setTimeout(function () {
// ...
}, 10000);
// or
.then(() => {
// ...
({ timeout: 10000 });
});
Also in JavaScript:
- const js +=
- javascript confirm yes no
- variables in js class
- how will it look when there is a container inside a a row bootstrap
- definition destructuring react
- javascript to get value of dropdown
- how to add data modal target attribute in jquery
- js before unload
- running scripts is disabled on this system react js
- reload a child component in angular
- reference error $ is not defined jquery
- get attribute value jquery href
- scroll to top router link vue
- USA phone number validator angular
- o que é jsonm
- define an unsigned int js
- axios response.json
- json decode android
- uncheck checkbox when another is checked javascript
- javascript change frame background
- bring to front svg html
- node test unit
- jstl expects equals
- invoking jquery validator