title: Append to constructor
body: <p>This object constructor is the definition of a person:</p>
  
  <pre><code>var Person = function( age, name ){
      this.age = age;
      this.namge = name;
  };
  </code></pre>
  
  <p>this is a line of code that will give the prototype of Person an array called "active"</p>
  
  <pre><code>Person.prototype.active = [];
  </code></pre>
  
  <p>The reason I am adding this to the prototype, is so that there is only one <code>active</code> array that every person, meaning Jim in this case: <code>var Jim = new Person()</code> ), SHARES the exact <em>same</em> active array.</p>
  
  <p>From that point I want to add in every newly created person into the active array. 
  This is how I would do it:</p>
  
  <pre><code>var Jim = new Person(age, name);
  Jim.active.push( Jim );
  var Tim = new Person(age, name);
  Tim.active.push( Tim );
  </code></pre>
  
  <p>What I expected from this, is for Tim.active[0] to be Jim and for
  Jim.active[1] to be Tim. </p>
  
  <p>The problem is, is that I want the <code>active.push[ self id ]</code> to be called 
  when a new Person is created, without the second line doing it. My solution for this would be modifying the Person constructor too look like this:</p>
  
  <pre><code>var Person = function( age, name ){
      this.age = age;
      this.namge = name;
  
      this.active.push( this );// The constructor now adds itself to the array during initiation 
  };
  </code></pre>
  
  <p>As you can see, it puhes itself into the <code>active</code> array. The problem is that I want my object to do exactly this, but I want the constructor to begin like the first one I provided with <code>this.active.push</code> appended later in the code.</p>
  
  <p>How do I expect this to be solved? My thoughts were that since the <code>active</code> array could be initiated anytime inside the program, that the functions constructor could somehow append <code>this.active.push()</code> to the end of it at right after <code>Person.prototype.active = []</code> is executed.</p>
  
  <p>Something that may look like:</p>
  
  <pre><code>Person.prototype.active = [];
  Person.prototype.append( function(){this.active.push(this)} );
  </code></pre>
  
  <p>The second line would morph the first object constructor to look like the second one.</p>