title: Typescript push to specific key in array
body: <p>I am working on Angular2 project using Firebase.</p>
  
  <p>I need to push all query results under the same key in <code>this.guestPush</code>.</p>
  
  <p>I have a multiple select element which contains different user levels. 4, 6, 9.</p>
  
  <p>When one level is selected, the resulting object is saved in the <code>guestPush</code> array, but when another level is selected the following error occurs.</p>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>ERROR TypeError: <em>this.guestPush[("filter</em>" + i)].push is not a function</p>
  </blockquote>
  
  <p>Here is my code : </p>
  
  <pre><code>  guestPush: any[] = new Array;
  
    level.forEach((lvl, index) =&gt; {
  
      this.db.object(`levelsUsers/${lvl}/users`)
        .subscribe(users =&gt; {
  
          if (this.guestPush['filter_' + i]) {
            this.guestPush['filter_' + i].push(users);
          } else {
            this.guestPush['filter_' + i] = users;
          }
  
        }, err =&gt; console.log(err));
  
    });
  </code></pre>
  
  <p>Edit ***</p>
  
  <p>The users object which contains the user or users which match the filter:</p>
  
  <pre><code>Object {-KmSjAaxdCUvrPEQ8InI: Object, $key: "users", $exists: function}
    -KmSjAaxdCUvrPEQ8InI: Object
      admin:"false"
      description:"desc"
      ...
      ...
      verified:false
    __proto__:Object
    exists:function ()
    $key:"users"
    __proto__:Object
  </code></pre>
  
  <p>And <code>this.guestPush[i] = users;</code> creates an object like this: </p>
  
  <pre><code>[Object]
   0:Object
   -KmSjAaxdCUvrPEQ8InI: Object
      admin:"false"
      description:desc"
      ...
      ...
      verified:false
      __proto__:Object
    $exists:function ()
    $key:"users"
    __proto__:Object
   length:1
   __proto__:Array(0)
  </code></pre>
  
  <p>So in the next loop I want to add any new user objects next to <code>-KmSjAaxdCUvrPEQ8InI</code> or anything as long as it is added as a value of the <code>0</code> key.</p>