Skip to main content

Posts

Showing posts from May, 2019

Javascript 106 : Promises

This post is a continuation of "Javascript 105: Callbacks". So If you have not studied the last post please go back and then come back to this.  As discussed in the last post, a callback is a way to force synchronous (sequential) operation of otherwise asynchronous tasks. Since this is a continuation lets begin from where we left off with the last post.  Take a look at this code, and its output.  Output:  We did that to ensure the statements prints in order This is okay for situation like this.  But imagine a code as follows Output: Take a look at the code and the output carefully. It is obvious that these statements are printing out of order due to the inherent asynchronous nature of JS.  If we still want to ensure that they take their own time to execute but still executing the way we want, how do you think that we can make this happen.  Sure, we can create multiple callback functions and call them inside of each (Which I even do not w