title: convert smarty array to javascript array
body: <p>I have a smarty array</p>
  
  <pre><code>$promoFormData  Smarty_Variable Object (3)
                          -&gt;value = Array (1)
                              deliveryDates =&gt; Array (3)
                                   0 =&gt; Array (2)
                                        startDate =&gt; "2013/06/05"
                                        endDate =&gt; "2013/06/28"
                                  1 =&gt; Array (2)
                                        startDate =&gt; "2013/07/05"
                                        endDate =&gt; "2013/07/28"
                                  2 =&gt; Array (2)
                                        startDate =&gt; "2013/08/05"
                                        endDate =&gt; "2013/08/28"
  </code></pre>
  
  <p>I want to use this array deliveryDates as available dates in datepicker.
  So trying to convert the above as the following Javascript array</p>
  
  <pre><code>var ranges = [ { start: new Date(2013, 06, 05), end: new Date(2013, 06, 28) },
                 { start: new Date(2013, 07, 05), end: new Date(2013, 07, 28) },
                 { start: new Date(2013, 08, 05), end: new Date(2013, 07, 28) } ];
  </code></pre>
  
  <p>I have tried using below code: </p>
  
  <pre><code> &lt;script&gt;
      var js_array = new Array();
      {{foreach from=$promoFormData.deliveryDates item=array_item key=id}}
          {{foreach from=$array_item item=sub_array_item key=index}}
              js_array['{{$id}}']['{{$index}}'] = '{{$sub_array_item}}';
          {{/foreach}}
      {{/foreach}}
  
      console.log(js_array);
  &lt;/scirpt&gt;
  </code></pre>
  
  <p>And I am getting the below error </p>
  
  <pre><code>     TypeError: js_array[0] is undefined
       js_array['0']['startDate'] = '2013/06/05';
  </code></pre>
  
  <p>Anyone please guide me to the right way.</p>