title: Circular object Array returned when attempting to extract contiguous sub-arrays
body: <p>I want to find all contiguous sub-array from a given array.</p>
  
  <p>For example, given array <code>[1,2,3]</code> I want to extract all contiguous sub-arrays:</p>
  
  <pre><code>[[1],[2],[3],[1,2],[1,2,3],[2,3]]
  </code></pre>
  
  <p>in any order.</p>
  
  <p>I've attempted at a solution here: <a href="https://codepen.io/loganlee/pen/XWbPKeR?editors=0011" rel="nofollow noreferrer">https://codepen.io/loganlee/pen/XWbPKeR?editors=0011</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let a = [1, 2, 3];
  
  let store = [];
  
  a.forEach(
    (n, i) =&gt; {
      store.push([n]);
      let nested = [n];
      for (let index = i + 1; index &lt; a.length; index++) {
        nested.push(a[index]);
        store.push(nested);
      }
    }
  );
  
  console.log(store);</code></pre>
  </div>
  </div>
  </p>
  
  <p>I get log of store here:</p>
  
  <pre><code>[[1],[1,2,3],[circular object Array],[2],[2,3],[3]]
  </code></pre>
  
  <p>When I expect</p>
  
  <pre><code>[[1],[1,2],[1,2,3],[2],[2,3],[3]]
  </code></pre>
  
  <p>I'm not sure why "circular object Array" is present, and why [1,2] is missing.</p>
  
  <p>Thank you very much!</p>