Skip to Main Content
Coding with JavaScript For Dummies
book

Coding with JavaScript For Dummies

by Chris Minnick, Eva Holland
May 2015
Beginner content levelBeginner
360 pages
6h 39m
English
For Dummies
Content preview from Coding with JavaScript For Dummies

Chapter 15

Understanding Callbacks and Closures

In This Chapter

arrow Understanding callback functions

arrow Using callbacks

arrow 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.

ontheweb Don’t forget to visit the website to check out the online exercises relevant to this chapter!

What Are Callbacks?

remember JavaScript functions are objects. This statement is the key to understanding many of the more advanced JavaScript topics, including callback functions.

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

HTML5 Programming with JavaScript For Dummies

HTML5 Programming with JavaScript For Dummies

John Paul Mueller
JavaScript For Kids For Dummies

JavaScript For Kids For Dummies

Chris Minnick, Eva Holland

Publisher Resources

ISBN: 9781119056072Purchase book