Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Nested Callbacks

Now we are getting closer to achieve the same effect as before, but without blocking our code from further execution. What we did is that we added the 'Nightking' as the ruler of westeros ('Night finds them all' after all), right 2 seconds after danny's reign. As you probably guessed we used another timeout function right after danny's sit on the throne. This is what we call a nested callback, and they are very common when we want to perform an asynchronous operation right after another has finished

For example i make a request to youtube server to bring me the video with the title i wanted. Youtube parses this request and finds the video. In the meantime i can do other things on my screen, when the video is ready and back, automatically another async operation can be made sequentially (like bringing on the aside section of the screen relevant videos that were uploaded from the same account etc). Then we must used nested callbacks, to clarify that WHEN the first async operation is finished and was succesful, do again something else.