title: passing parent object automatically
body: <p>So I have a couple of classes</p>
  
  <pre><code>function BaseClass(x, y){
      this.x = x;
      this.y = y;
  }
  
  function ImageClass(img, w, h, x, y){
      BaseClass.call(this, x, y);
      this.img = img;
  }
  ImageClass.prototype = Object.create(BaseClass.protoype);
  ImageClass.prototype.constructor = ImageClass;
  
  function LayerClass(img, w, h, x, y){
      ImageClass.call(img, w, h, x, y);
      this.collection = [];
      this.createSprite = function(img, r, a, w, h, x, y){
          this.collection.push(new Sprite(img, r, a, w, h, x, y));
      }
  }
  LayerClass.prototype = Object.create(ImageClass.prototype);
  LayerClass.prototype.constructor = LayerClass;
  
  function SpriteClass(img, r, a, w, h, x, y){
      ImageClass.call(img, w, h, x, y);
      this.r = r;
      this.a = a;
  }
  SpriteClass.prototype = Object.create(ImageClass.prototype);
  SpriteClass.prototype.constructor = SpriteClass;
  </code></pre>
  
  <p>In my code each of the inherited classes uses call() to pass 'this'</p>
  
  <p>The problem being is that if I have a Layer object that contains any Sprite objects, I would like the Sprite objects to have a parent (super) reference and I can't do this because the class constructors use this to set properties.</p>
  
  <p>So does anyone know how I could pass the parent or (and I know this is going to sound dumb, it's late) be able to get the parent scope this in the class constructor?</p>
  
  <p>While writing this I realized that it might be as simple as setting the parent property after the object is set as a child but I'm looking for confirmation if that's the best way or if anyone knows something better. Also feel free to tell me I know nothing about prototype because I'm still learning it. :-)</p>
  
  <p>-Thanks</p>