DEV Community

Ed Stokes
Ed Stokes

Posted on

What is a Callback function?

A callback function is a function that is passed into another function as an argument. In javascript actions are asynchronous, which basically means a fuction will run in the background instead of the code stopping and waiting on the function to executed before continuing. In order for this to work we need promises that will be resolved by a successful completion of the function or the fuction being rejected with sometype of error being returned. Callback functions can be used in response to an event such as a mouse click, this allows for user interaction in the program without the progrmam stopping execution.

Top comments (0)