Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Using Anonymous Functions with setInterval1:33 with Andrew Chalkley
In this video we'll explore using anonymous functions with `setInterval`.
I challenge you to try and
use an anonymous function with the setInterval function.
And to think if it's possible to use one with our clock application.
While it is possible to use an anonymous function with the set interval function,
we shouldn't really use one in this application, let me show you why.
Let me cut and paste tickClock into this
setInterval function, and make it anonymous.
But what happens to the tickClock invocation outside of the setInterval?
We don't have the function to call anymore,
let's comment out this line, save, and preview it.
We see clock goes here, and then it starts ticking, this behavior is not desirable.
Because we need to update the clock display when the page loads,
we can't wait for the first setInterval call.
The clock application isn't really suited for an anonymous function.
So I'm going to revert my code back to include the named function, tickClock.
Being comfortable using named and
After you've experimented with the code, you'll need to exercise judgment.
And when you start making judgment calls like that,
you're becoming a more mature developer
You need to sign up for Treehouse in order to download course files.Sign up