title: Uncaught TypeError: Cannot set property 'product_id' of undefined
body: <p>I'm attempting to do a multidimensional array in jQuery.  </p>
  
  <pre><code>var parent = $(this).parents(".product:first").find(".decking_var_content &gt; li");
  var product_id = $(this).parents('.product:first').find( '.variations_form').find('input[name=product_id]').val();
  var myarray = [];
  
  parent.each(function() {
      var var_id = $(this).find("span").attr("data-id");
      var quantity = $(this).find(".decking_var_child_ul").find("input[name=quantity]").val();
  
      if (var_id) {   
          myarray[var_id]['product_id'] = product_id; //error points here
          myarray[var_id]['quantity'] = quantity;
          myarray[var_id]['variation_id'] = var_id;
      } 
      else {
          myarray[product_id]['quantity'] = quantity;
      }
  });
  </code></pre>
  
  <p>The error points at this <code>myarray[var_id]['product_id'] = product_id;</code>  .
  I have alerted <code>product_id</code> so i know it holds a value.</p>
  
  <p>How do I solve this?</p>