title: What does the first 'for' do in 'inheritance' Typescript code?
body: <p>I was reading the <a href="http://www.typescriptlang.org/Playground" rel="nofollow">typescript page</a> and in the "Inheritance" section I found this function: </p>
  
  <pre><code>var __extends = (this &amp;&amp; this.__extends) || function (d, b) {
  for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  function __() { this.constructor = d; }
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
  </code></pre>
  
  <p>And when I was reading this line:</p>
  
  <pre><code>for (var p in b)...
  </code></pre>
  
  <p>I had a question: what does this loop do exactly?</p>
  
  <p>I tried to understand this and I change:</p>
  
  <pre><code>for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  </code></pre>
  
  <p>to</p>
  
  <pre><code>for (var p in b){
      console.log(p);
      if (b.hasOwnProperty(p)) d[p] = b[p];
  }
  </code></pre>
  
  <p>because I wanted to know the value of <code>p</code>, but the console didn't show anything!</p>
  
  <p>At first I thought this <code>for</code> copies <code>b</code>s attributes to <code>d</code>. But I'm not sure right now because I think this loop is not performing any iteration.</p>
  
  <p>I don't understand this <code>for</code> loop. Can anybody help me?<br>
  Until now I think that <code>for</code> is useless for that code, but I want to know what <em>you</em> think.</p>
  
  <p>Here is the complete code i have:</p>
  
  <pre><code>var __extends = (this &amp;&amp; this.__extends) || function (d, b) {
  for (var p in b){
      console.log("iteration");
      console.log(p);
      if (b.hasOwnProperty(p)) d[p] = b[p];
  }
  function __() { this.constructor = d; }
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
  var Animal = (function () {
      function Animal(name) {
          this.name = name;
      }
      Animal.prototype.move = function (meters) {
          alert(this.name + " moved " + meters + "m.");
      };
      return Animal;
  })();
  var Snake = (function (_super) {
      __extends(Snake, _super);
      function Snake(name) {
          _super.call(this, name);
      }
      Snake.prototype.move = function () {
          alert("Slithering...");
          _super.prototype.move.call(this, 5);
      };
      return Snake;
  })(Animal);
  var Horse = (function (_super) {
      __extends(Horse, _super);
      function Horse(name) {
          _super.call(this, name);
      }
      Horse.prototype.move = function () {
          alert("Galloping...");
          _super.prototype.move.call(this, 45);
      };
  
  
  return Horse;
  })(Animal);
  var sam = new Snake("Sammy the Python");
  var tom = new Horse("Tommy the Palomino");
  sam.move();
  tom.move(34);
  </code></pre>
  
  <p>I don't see anything in console.</p>