title: Unhandled Promise Rejection: TypeError:
body: <p>A very strange behavior is happening..</p>
  
  <p>This works...</p>
  
  <p><a href="https://jsfiddle.net/ymgzrped/" rel="nofollow noreferrer">https://jsfiddle.net/ymgzrped/</a></p>
  
  <p>But this below version does not...</p>
  
  <p><a href="https://jsfiddle.net/ymgzrped/1/" rel="nofollow noreferrer">https://jsfiddle.net/ymgzrped/1/</a></p>
  
  <p>I changed...</p>
  
  <pre><code> function fillInAddress()
  </code></pre>
  
  <p>to </p>
  
  <pre><code> function fillInAddress(mapcomponents) 
  </code></pre>
  
  <p>Used like this (working)</p>
  
  <pre class="lang-js prettyprint-override"><code>autocomplete.addListener('place_changed', fillInAddress)
  </code></pre>
  
  <p>and this (not working)</p>
  
  <pre class="lang-js prettyprint-override"><code>autocomplete.addListener('place_changed', fillInAddress(new_mapcomponents))
  </code></pre>
  
  <p>For some reason, when I pass a parameter in, I get an error:</p>
  
  <pre><code>Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'place.address_components')
  fillInAddress — _display:176
  initAutocomplete — _display:162
  (anonymous function) — js:145:280
  (anonymous function) — js:145:119
  promiseReactionJob
  https://jsfiddle.net/js/makeStreamConfig.js.map
  </code></pre>
  
  <p>It seems to be some sort of scoping error with the code when I pass a parameter, but not when I do not.  </p>
  
  <p>What would cause this?</p>
  
  <p>Thank you</p>