title: Insert object inside an array
body: <p>I need to save some data in an array. But these objects are dynamically inserted from the user input so the input is done by iterating. </p>
  
  <pre><code>    data2 = {};
  
      for(j=0;j&lt;ebs_no;j++){
          for(k=0;k&lt;$('[name=snap_no'+j+']').val();k++){
              data2[i].snapshot.push({
                  duration : $('name=duration'+j+k).val(),
                  every : $('name=every'+j+k).val(),
                  keep : $('name=keep'+j+k).val()
              });
          }
      } 
  </code></pre>
  
  <p>I am getting an error</p>
  
  <blockquote>
    <p>Cannot read property '<code>snapshot</code>' of undefined</p>
  </blockquote>
  
  <p>and app is crashing down.</p>
  
  <p>the end out put should something like this</p>
  
  <pre><code>   { 
      ebs:[{duration : String,
                  every : Number,
                  keep : Number
           }]
     }
  </code></pre>