javascript wait 5 sec
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!");function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}function stateChange(newState) {
setTimeout(function () {
if (newState == -1) {
alert('VIDEO HAS STOPPED');
}
}, 5000);
}
timeout(ms) { //pass a time in milliseconds to this function
return new Promise(resolve => setTimeout(resolve, ms));
}
Also in JavaScript:
- bootstrap 4 form validator with jquery
- flutter asset image not showing
- javascript turn string into array
- how to use await to console
- jquery remove option from select by value
- rounding number to x decimals javascript
- download comma separated file, react
- chrome add a javascript bookmark
- how to get img dimensions from remote url js
- simple return data jquery
- javascript 2 decimal float array elements
- object destructuring default value
- selector id jquery but is variable
- bigint type js
- $.post javascript
- add new items in a select input using js
- refresh page on button click jquery
- hide warnings in expo app
- jquery ajax responseText
- get value from textbox in vanilla javascript
- react native touchableopacity disable
- checking ascii in js
- node send file
- tableau js api