From the course: JavaScript Essential Training

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Callbacks

Callbacks

- [Instructor] Sometimes we have two functions and we want to control the sequence at which they execute. This typically happens if one function relies on the output of another function for data or when one function has to wait for another function to complete before doing something. One way of handling this type of function sequencing is through what's known as a callback function and this is a traditional method for handling this type of problem and you will come across it all the time. In the exercise files for this movie I've updated our tip calculator example a little bit. So from the bottom, the tip calculator function now creates an object named final tip with all of the data. This object uses the format or function we created previously to format the number values and nothing is new here, except for that object. What is new is directly above here is this new callback function called…

Contents