title: Constructor function. Can't overwrite reference to global variable
body: <p>I use this constructor to make objects for a game.
  Right now, the series of images gets overwritten everytime, such that all the objects look the same on screen.</p>
  
  <p>Here's the object in question:</p>
  
  <pre><code>function Box() {
      this.ready = false;
      this.pics = pictures;//[];
      this.state = 0;
      this.x = 0;
      this.y = 0;
      this.w = 1;
      this.h = 1;
      this.fill = "#444";
      this.load = function(array){
          var foo = [];
          pictures = [];
          for(var i = 0; i &lt; array.length; i++){
              pictures.push(loadPic(array[i]));
              foo.push(loadPic(array[i]));
          }
          //this.pics = pictures;
          this.pics = foo;
      }
  }
  </code></pre>
  
  <p>The line</p>
  
  <pre><code>this.pics = foo;
  </code></pre>
  
  <p>seems to do nothing at all.</p>
  
  <p>Also, if I change the initial value of pics to anything but "pictures" (which is a global variable) the game does not start.</p>
  
  <p>Contex: <a href="https://github.com/kaninepete/Javascript-Games/blob/images/MVP.js" rel="nofollow">https://github.com/kaninepete/Javascript-Games/blob/images/MVP.js</a></p>