I have a function that that I would like to call immediately, then use setInterval to update every ten seconds.
Currently I am using something like
myFunction();
setInterval(function(){
myFunction();
}, 10000);
Is there a better way to do this? I feel like there should be a way to tell setInterval to fire on call, but I cannot seem to find anything on it.
This isn't any "better," but it does what you want with fewer lines:
myFunction();
setInterval(myFunction, 10000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With