title: Self-pushing object constructor
body: <p>So JavaScript is a functional language, classes are defined from functions and the function scope corresponds to the class constructor. I get it all now, after a rather long time studying how to OOP in JavaScript.</p>
  
  <p>What I want to do is not necessarily possible, so I first want to know if this is a good idea or not. So let's say I have an array and a class like the following:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>var Entry = function(name, numbers, address) {
    this.name = name;
    if(typeof numbers == "string") {
      this.numbers = [];
      this.numbers.push(numbers);
    }
    else this.numbers = numbers;
    this.address = address;
  };
  
  var AddressBook = [];
  </code></pre>
  
  <p>And I add contacts with the following function:</p>
  
  <pre class="lang-js prettyprint-override"><code>function addContact(name, numbers, address) {
    AddressBook.push(new Entry(name, numbers, address));
  }
  </code></pre>
  
  <p>Can't I make it so <code>new Entry()</code> would put <strong>itself</strong> into <code>AddressBook</code>? If I can't do this on create, it would be interesting to do it with a method in the <code>Entry</code> prototype as well. I couldn't figure out a way to do anything similar.</p>