Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda What Are Callbacks? | Foundations of Asynchronous JavaScript
Asynchronous JavaScript Explained

bookWhat Are Callbacks?

A callback is a function that you pass as an argument to another function, so that it can be executed later—often after an asynchronous operation completes. In asynchronous programming, callbacks are essential because they let you specify what should happen once a time-consuming task, like reading a file or waiting for a timer, is finished. This pattern helps you avoid stopping the entire program while waiting for something to complete.

script.js

script.js

index.html

index.html

copy

Callbacks make it possible for your code to keep running without waiting for long tasks to finish. Instead of blocking the program, you hand off a callback function to be called once the asynchronous operation is done. This way, your program remains responsive and efficient, handling other work while waiting for results.

question mark

What is a callback function?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 8

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Awesome!

Completion rate improved to 3.57

bookWhat Are Callbacks?

Deslize para mostrar o menu

A callback is a function that you pass as an argument to another function, so that it can be executed later—often after an asynchronous operation completes. In asynchronous programming, callbacks are essential because they let you specify what should happen once a time-consuming task, like reading a file or waiting for a timer, is finished. This pattern helps you avoid stopping the entire program while waiting for something to complete.

script.js

script.js

index.html

index.html

copy

Callbacks make it possible for your code to keep running without waiting for long tasks to finish. Instead of blocking the program, you hand off a callback function to be called once the asynchronous operation is done. This way, your program remains responsive and efficient, handling other work while waiting for results.

question mark

What is a callback function?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 8
some-alt