title: javascript set property in array
body: <p>I want to set the property(p1) of an item in an array.
  For example, array[1].p1="David". But an error happened.
  Following is the code, could someone give me a hint?Many thanks.</p>
  
  <pre><code>    var array1=new Array();         
  
          array1[0].p1="MARY";
          array1[1].p1="JHON";
          for (index = 0; index &lt; array1.length; ++index) {
              alert(array1[index].p1);            
          }       
  </code></pre>
  
  <p>I`ve tried array1.push({p1:"MARY"}), it works! But it can not set the value by "particular" index.</p>