JavaScript Timers - setTimeout, setInterval, clearTimeout, and clearInterval

preview_player
Показать описание
How to use the built-in timer functions which allow you delay your function calls.

Рекомендации по теме
Комментарии
Автор

Can not thank you enough for these god-sent tutorials. My only hope is that please make more and more. Your knowledge can help many people like me, and hope more students will find this channel, It is a waste of resource when I see the number of viewers.

rotrose
Автор

You explained this perfectly thank you so much. Was confused about assigning the timeouts to a variable name.

WalrusMcDonaldnna
Автор

A bit long, but nevertheless effective.
Thank you for your help, I couldn't get my head around these w3 schools and stack overflow tutorials (;

MiSt
Автор

I love the sound of the mouse click, together with the calm voice it's very relaxing

jrs_devs
Автор

Aside from the interval and timeout methods, those i understand, something else hit me. How is declaring a variable initiating that function or its value?



function test(){
console.log('this function was executed');
}
let x = test();
let y = 10;
In the variable y its being internally saved on memory and not computed with until asked for, but declaring a function automatically runs it ?

justaprogrammer
Автор

I didn't get why I would want to clear the setTimeout since it's running only once?

IvoTsochev
Автор

What if you wanted to setInterval function to run immediately, as well as at each interval? So for the first call...you don't want any delay.

andrewgarfinkel
Автор

Ah. That is why you get an "invalid callback error" from setInterval(callback(deets), 500);
You have to use setInterval(callback, 500, deets);

Thank you.

bodaciouschad
Автор

What if you want setInterval( ) to run more than just once? How would you do that? And what is the point of setInterval( ) if you can't turn it off normally?

Martin
Автор

Would there be a way to use setTimeout &| setInterval to send continuous http requests to something?

Kind of like a scuffed slow http?

FordExplorer-rmew
Автор

Are the Timers asynchron? Like can i run othere code while the are counting ?

de-kat
Автор

I've been trying to figure this out, just recently started to study JS. Why does this happen if I write this:

var tick = true; 

function ticker() {
if(tick) {
console.log("Tick");
tick = false;
} else {
console.log("Tock");
tick = true;
}
}
setInterval (ticker, 1000);

Everything works as expected. It tick tocks every second.

But if I place the variable tick within the scope of the function ticker, it's value is not changed to false, and the console.log keeps printing only tick. It confuses me
I feel that there is something very important for me to understand here!

kllokoq
Автор

How can I set the delay time if it's offline when the data in database is delayed after 3 minutes?

ayroserosli
Автор

There is 20 second time how to kill it

chvishnu
Автор

Hi Sir PL provide a script for captcha above URL

chvishnu
Автор

It's hard to focus with the keyboard clicks and the sound of the computer fan. If you used an external microphone, your videos would 1, 000 more enjoyable. Otherwise awesome video.

sethortiz
join shbcf.ru