title: Calling a function from an object string compared to an object function
body: <p>Why if I use</p>
  <pre class="lang-js prettyprint-override"><code>const TokenProperties = {
    access_token: PropertiesService.getScriptProperties().getProperty(&quot;access_token&quot;)
  }
  </code></pre>
  <p>instead of</p>
  <pre class="lang-js prettyprint-override"><code>const TokenProperties = {
    access_token: ()=&gt; PropertiesService.getScriptProperties().getProperty(&quot;access_token&quot;)
  }
  </code></pre>
  <p>and</p>
  <pre class="lang-js prettyprint-override"><code>function getAccessToken() {
  
    // Makes REST API POST request for access token...
    // .......
  
    PropertiesService.getScriptProperties()
      .setProperty(&quot;access_token&quot;, access_token);
    return access_token;
  }
  
  
  function restCall (){
    
    checkToken(); // Let's say the access token is expired and this function calls getAccessToken() 
  
    // Why does...
    var restEndpoint = &quot;https://api.........&quot;
    var head = {
      &quot;Authorization&quot;:&quot;Bearer &quot;+ TokenProperties.access_token,   // &lt;- This doesn't use the new token
      &quot;Authorization&quot;:&quot;Bearer &quot;+ TokenProperties.access_token(), // &lt;- This does (as I wanted)
      &quot;Content-Type&quot;: &quot;application/json&quot;
    }
  }
  </code></pre>
  <ul>
  <li>Doesn't that line of code gets run after <code>checkToken()</code> is finished?</li>
  <li>What is the difference when calling the function from an object string <br />
  compared to calling it as an object function?</li>
  <li>How is the ordering of the functions getting called in the call stack?</li>
  <li>Should I be doing it like this? What would be the best practice?</li>
  </ul>