Chapter 15
Understanding Callbacks and Closures
In This Chapter
Understanding callback functions
Using callbacks
Creating closures
“O, call back yesterday, bid time return.”
— William Shakespeare
Callbacks and closures are two of the most useful and widely used techniques in JavaScript. In this chapter, you find out how and why to pass functions as parameters to other functions.
What Are Callbacks?
Functions, like any other object, can be assigned to variables, be passed as arguments to other functions, and created within and returned from functions.
Passing functions as arguments
A callback function is a function that is passed as an argument to another function. Callback functions are a technique that’s possible in JavaScript ...
Get Coding with JavaScript For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.