JavaScript Timers Flashcards
What is a “callback” function?
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
Besides adding an event listener callback function to an element or the document, what is one way to delay the execution of a JavaScript function until some point in the future?
To delay a function call, use setTimeout() function
How can you set up a function to be called repeatedly without using a loop?
setInterval(function, milliseconds ) Same as setTimeout(), but repeats the execution of the function continuously.
What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?
If you omit it, the delay defaults to 0.
What do setTimeout() and setInterval() return?
setInterval() a numeric, non-zero value
The setTimeout() returns a timeoutID which is a positive integer identifying the timer created as a result of calling the method.
timeoutID is the positive integer
setTimeout allows us to run a function once after the interval of time. setInterval allows us to run a function repeatedly, starting after the interval of time, then repeating continuously at that interval