O'Reilly logo

Sams Teach Yourself Node.js in 24 Hours by George Ornbo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hour 4. Callbacks

What You’ll Learn in This Hour:

• What callbacks are and how they are used in JavaScript

• How callbacks are used in Node.js

• The difference between synchronous and asynchronous programming

• What an event loop is

What Is a Callback?

If you are familiar with using jQuery, you are probably using callbacks on a regular basis. A callback is a function that is passed as an argument to another function and is generally called when the first function is finished. In the following jQuery example, a paragraph tag is hidden using jQuery’s hide() method. This method takes an optional argument of a callback function. If a callback function is given as an argument, it will be called when the hiding of the paragraph is complete. This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required