+1 vote
in Mean Stack by
What is meant by “Callback” in Node.js?

1 Answer

0 votes
by

In Node.js, a callback is an asynchronous equivalent for a function. Node.js heavily relies on callbacks that are called at the culmination or completion of a given task. For instance, let’s assume a function that is designed for reading files may start reading files and immediately return the control to the execution environment to facilitate the execution of the next instruction.

Once the file I/O is complete, the callback function is set in motion and pass the content of the file as a parameter. This makes sure that there’s no blocking or waiting for the file I/O. It is this feature that makes Node.js highly scalable since it can process a high number of requests without waiting for the results of any function. 

All Node APIs are written in ways that they can support callbacks.

Related questions

+1 vote
asked Jun 20, 2021 in Mean Stack by SakshiSharma
0 votes
asked Oct 31, 2023 in Mean Stack by Robin
...