Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
In this video we'll recap what you've learned with callbacks.
-
0:00
[MUSIC]
-
0:04
Well done.
-
0:05
Callbacks can be challenging but they're a powerful tool in asynchronous,
-
0:09
event based programming.
-
0:11
They're everywhere in JavaScript.
-
0:13
I encourage you to take the course again if you're still having problems
-
0:17
surrounding callbacks.
-
0:18
The second time through, there may be some more a ha moments.
-
0:22
Let's recap on some of the things that you've learned.
-
0:25
Functions are often referred to as first class objects in JavaScript.
-
0:29
All this means is that a reference to the function can be passed around
-
0:33
just like any other variable.
-
0:35
Remember, a callback function is like any other.
-
0:39
Instead of call by you in the code it's being triggered by a system event.
-
0:44
In the case of setTimeout,
-
0:46
the callback is invoked after a delay which is supplied as a second argument.
-
0:51
Remember, you don't include parenthesis when you pass in the name of
-
0:55
the functioning since that would invoke the function immediately.
-
1:00
Callbacks can be expressed as an anonymous function too or an arrow function.
-
1:06
Some callbacks can have arguments passed in.
-
1:09
In the case of the addEventListener,
-
1:12
the callback can have a single argument passed in, the event object.
-
1:17
Callbacks are everywhere in JavaScript, whether you stay in the front-end, or
-
1:21
move over to the back-end with Node.js.
-
1:23
You'll encounter them in all of your JavaScript developer life.
-
1:27
I hope you enjoyed this course, and until next time, keep on coding.
You need to sign up for Treehouse in order to download course files.
Sign up