Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
In this video we'll modify the `setTimeout` call to use an anonymous function.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
How did you do?
0:00
Did you convert the function
to an anonymous function and
0:00
did you use it as a call back.
0:04
If not, let's practice the steps again.
0:06
If you were able to jump to the solution,
great.
0:09
You may want to skip
the rest of this video.
0:12
If you still need to practice getting
your head around anonymous functions,
0:14
follow along.
0:18
Let's convert the function declaration
into a function expression.
0:19
A function expression is where you assign
a function to a variable, showSurprise.
0:24
To convert a function expression
to an anonymous function just
0:37
simply delete the variable assignment,
there you have it,
0:41
an anonymous function isn't any
use outside of being a callback.
0:46
Finally, cut and
paste the anonymous function as
0:52
the first parameter of
the setTimeout function.
0:56
You can go a step further and
make it an arrow function like this.
1:03
Or, you can use the arrow function
on a single line, like this.
1:11
If you're not comfortable with
arrow functions yet, don't worry.
1:21
They can take some getting used to.
1:25
Even for a seasoned JavaScript developer.
1:27
We'll have more opportunities
in the rest of this course and
1:29
future courses to practice
with that syntax.
1:32
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