javascript-timers Flashcards

1
Q

What is a “callback” function?

A

A function that is passed to another function to be called inside the function it was passed to.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is one way to delay the execution of a JavaScript function until some point in the future?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can you set up a function to be called repeatedly without using a loop?

A

The setInterval() method can be used with the first argument being the function to repeatedly call, the second argument being the interval delay.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?

A

The default time delay is the parameter is omitted is 0 milliseconds, which calls the function immediately.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What do setTimeout() and setInterval() return?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly