title: Block scope variable gets value set in anonymous function within block but this value is not available outside the function
body: <p>I'm trying to update the value of <code>start</code> inside an anonymous function contained within the block but this does not seem to be happening.</p>
  <p>When I declare a variable with <code>let</code>, I imagined that this variable would be block scoped and it's value could be updated by anonymous functions within the block.</p>
  <p>What am I doing wrong?</p>
  <pre><code>function getStartTime(Id) {
    let start = '';
    let bQuery = &quot;select StartTime from database.table where Id=?&quot;;
    dbService.executeDQuery(bQuery, Id, function (error, rs_bs) {
      if (error) {
        next(error);
        return;
      }
      
      start = JSON.stringify(rs_bs[0][&quot;StartTime&quot;]);
      
      console.log(&quot;start in = &quot; + start); //shows the correct value
    });
    
    console.log(&quot;start out = &quot; + start); //this is empty
    
    return start; //nothing returned
  }
  </code></pre>