title: Assigning local reference to global
body: <p>here's what I can't understand.</p>
  <p>I have this function here</p>
  <pre><code>function foo(){
  let a = {a:1};
  window.a = a; 
  }
  </code></pre>
  <p>as you can see, this assign to <code>a</code> an object, so a reference to it, and then it creates a new property on the window object that contains this reference. If the <code>a</code> variable is local, it's reference point to an address in the stack, so, how can I access <code>a</code> from window, also out of the function, when the stack is cleaned?</p>