title: Node.js: Which parts of the code are executed following an asynchronous call?
body: <p>Asynchronous calls are an inherent part of javascript, and using callbacks is often an elegant tool to handle these calls.</p>
  
  <p>However, I am not quite sure how is the branching of code following an asynchronous operation decided. For example, what would happen with the following code?</p>
  
  <pre><code>function f(callback) {
     value = some_async_call();
     if (value) {
         callback(value);
     }
     return(value);
  }
  </code></pre>
  
  <p>What would happen here? From my short JS experience, <code>return</code> would send back an <code>undefined</code> value. But suppose that <code>value</code> returns true from the asynchronous call, would the callback be called with the right value or with an <code>undefined</code> value? </p>
  
  <p><strong>In other words, is there a rule regarding which operations are executed immediately after the async call, and which are deferred until the value is returned?</strong></p>
  
  <h1>What have I tried before asking</h1>
  
  <p>SFTW for branching asynchronous calls in javascript, but found nothing canonical or decisive.</p>