title: Javascript constructor: Accessing outside variable
body: <p>I try to access an object which is global; it's a kind of a preset.</p>
  
  <pre><code>var perks = {health: 100, attack: 10};
  
  var player = function(hp) {
     this.stats = perks;
  
     //Changing some standard values..
     this.stats["health"] = hp; 
  }
  
  var Peter = new player(200);
  var Steven = new player(300);
  </code></pre>
  
  <p>I hope you get my intention; the problem is, that it won't work correct, and I'm not even sure what it does wrong. If I create more than one player, e.g. Steven, Collin and James, every player has the same perks. In this example Peter and Steven both have 300 health.</p>
  
  <p>If I change the line</p>
  
  <pre><code>this.stats = perks;
  </code></pre>
  
  <p>to </p>
  
  <pre><code>this.stats = {health: 100, attack: 10};
  </code></pre>
  
  <p>everything works like intended. Peter and Steven both have their own stats.
  How do I access the global <code>var perks</code>?</p>