title: Javascript: Accessing array inside an object
body: <p>I have an array <code>cornerId</code> inside an object <code>elementMatrix</code>. Thereafter I want to create <code>elemArray</code> which is an array of the object <code>elementMatrix</code>. However I am not able to access the value of <code>cornerId</code>. </p>
  
  <pre><code>function elementMatrix() {
      var cornerId=new Array();
  }
  
  var elemArray=new Array();
  elemArray[0]=new elementMatrix();
  elemArray[0].cornerId[0]="z"; //if I put elemArray[0].cornerId="z"; then it works for the first element - but then how do I put second element???
  elemArray[0].cornerId[1]="a";
  alert(elemArray[0].cornerId[0]); // shows undefined
  alert(elemArray[0].cornerId[1]); //again undefined
  ....
  Add other elemArray values
  ....
  </code></pre>
  
  <p>I want to assign values and access values for the nth position of the array <code>cornerId</code>, which is a part of <code>elemArray</code> which is an array of object <code>elementMatrix</code>. Can anyone show me the right way to access <code>cornerId</code> values???</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>To clarify I want the liberty to add cornerId at the nth position (overwrite existing value) and not push it. Also I had not asked this originally but if there is a method to remove an nth position from cornerId then that will be great.</p>