title: Is google apps script synchronous?
body: <p>I'm a Java developer learning JavaScript and Google Apps Script simultaneously. Being the newbie I learned the syntax of JavaScript, not how it actually worked and I happily hacked away in Google Apps Script and wrote code sequentially and synchronous, just like Java. All my code resembles this: <em>(grossly simplified to show what I mean)</em></p>
  
  <pre><code>function doStuff() {
    var url = 'https://myCompany/api/query?term&lt;term&amp;search';
    var json = getJsonFromAPI(url);
    Logger.log(json);
  }
  
  function getJsonFromAPI(url) {
    var response  = UrlFetchApp.fetch(url);
    var json = JSON.parse(response);
    return json;
  }
  </code></pre>
  
  <p>And it works! It works just fine! If I didn't keep on studying JavaScript, I'd say it works like a clockwork. But JavaScript isn't a clockwork, it's gloriously asynchronous and from what I understand, this should not work at all, it would "compile", but logging the <code>json</code> variable should log undefined, but it logs the JSON with no problem.</p>
  
  <p><strong>NOTE:</strong></p>
  
  <p>The code is written and executed in the Google Sheet's script editor.</p>
  
  <p>Why is this?</p>