javascript КАК да настроите забавяне
var delayInMilliseconds = 1000; //1 second
setTimeout(function() {
//your code to be executed after 1 second
}, delayInMilliseconds);
таймер в javascript
//single event i.e. alarm, time in milliseconds
var timeout = setTimeout(function(){yourFunction()},10000);
//repeated events, gap in milliseconds
var interval = setInterval(function(){yourFunction()},1000);
забавяне в js
var delayInMilliseconds = 1000; //1 second
setTimeout(function() {
//your code to be executed after 1 second
}, delayInMilliseconds);
javascript изчакайте 5 секунди
timeout(ms) { //pass a time in milliseconds to this function
return new Promise(resolve => setTimeout(resolve, ms));
}
забавяне javascipt
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
console.log("Hello");
sleep(2000).then(() => { console.log("World!"); });