title: how javascript handles variables in objects?
body: <p>I have a question about declaring a variable in an object. Assuming that global or window is also an object, why is it not possible to declare a variable using let in an object that is a child of the window object? I do not understand that. Thanks for the answer and sorry for the English but I hope you understand the question.</p>
  <p>this doesnt worked</p>
  <pre><code>let a = 'global';
  console.log(a);
  const outsideObj = {
  
      let b = 'outside var',
      logIt() {
          console.log(this);
          console.log(a);
          console.log(this.b)
      }
  };
  
  outsideObj.logIt();
  </code></pre>
  <p>this worked</p>
  <pre><code>console.log(this);
  
  let a = 'global';
  console.log(a);
  
  const outsideObj = {
  
      b: 'outside var',
      logIt() {
          console.log(this);
          console.log(a);
          console.log(this.b)
      }
  };
  
  outsideObj.logIt();
  </code></pre>
  <p>i dont get difference between windows object and regular object why is it possible in parent and not in child?</p>