title: js scope and the window object?
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function Dog(name, age) {
    this.name = name;
    this.age = age;
    this.bark = function() {
      this.name += " hello";
      console.log(this.name);
      (function() {
        this.name += "a";
        console.log(this.name);
      })();
    }
  };
  let dog = new Dog("tep", 2);
  dog.bark();</code></pre>
  </div>
  </div>
  </p>
  <p>can anyone please tell me what happened here? when I open the console, It print 2 lines which are</p>
  <ul>
  <li>tep hello</li>
  <li>a</li>
  </ul>
  <blockquote>
  <p>every time I reload the page, it continue add the 'a' in line 2, and I
  saw in the window object, there is property &quot;name&quot;</p>
  </blockquote>
  <ul>
  <li>tep hello</li>
  <li>aa</li>
  </ul>