You are here: Home / Topics / Why do we use callbacks in Javascript?

Why do we use callbacks in Javascript?

Filed under: JavaScript Interview Questions on 2022-08-02 06:12:44

A callback function is a method that is sent as an input to another function (now let us name this other function "thisFunction"), and it is performed inside the thisFunction after the function has completed execution.

JavaScript is a scripting language that is based on events. Instead of waiting for a reply before continuing, JavaScript will continue to run while monitoring for additional events. Callbacks are a technique of ensuring that a particular code does not run until another code has completed its execution.

About Author:
R
Ruchi Sharma     View Profile
Queen, princess, and educational qualified student. Java master.