javascript-timers Flashcards
What is a “callback” function?
A function that is passed to another function to be called inside the function it was passed to.
What is one way to delay the execution of a JavaScript function until some point in the future?
Using the setTimeout() function with the function to be delayed as the first argument and the time to delay it in milliseconds for the second argument.
How can you set up a function to be called repeatedly without using a loop?
The setInterval() method can be used with the first argument being the function to repeatedly call, the second argument being the interval delay.
What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
The default time delay is the parameter is omitted is 0 milliseconds, which calls the function immediately.
What do setTimeout() and setInterval() return?
They return the “timeoutID” which is a positive integer value that identifies the timer and can be passed to clearTimeout() to cancel the timeout or stop the interval.