Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Callback Functions in JavaScript!

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
In this video, we'll use a repeat timer in the form of the `setInterval` function to modify the display of a clock.
Syntax
setInterval(callback, delay);
Where callback
is a function and delay
is the number of milliseconds between each invocation.
Canceling a Timeout
To cancel a interval at any time assign the interval to a variable and call the clearInterval
function.
const intervalID = setInterval(callback, delay);
//Clears the interval immediately
clearInterval(intervalID);
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Elizabeth Eymann
12,209 Points1 Answer
-
Ryan Soeder
11,056 Points1 Answer
-
Unsubscribed User
6,269 Points2 Answers
-
PLUS
Saud Tauqeer
Courses Plus Student 8,099 Points1 Answer
-
Martin Larsen
9,839 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up