title: JavaScript — Split an array like a string
body: <p>Is it possible to split an array into smaller arrays each time a specific value is found? In this case, every time <code>type</code> equals <code>&quot;divider&quot;</code>.</p>
  <p>Input:</p>
  <pre><code>[
      {
          &quot;type&quot;: &quot;type-a&quot;,
          &quot;name&quot;: &quot;Foo&quot;
      },
      {
          &quot;type&quot;: &quot;type-b&quot;,
          &quot;name&quot;: &quot;Foo&quot;
      },
      {
          &quot;type&quot;: &quot;type-c&quot;,
          &quot;name&quot;: &quot;Foo&quot;
      },
      {
          &quot;type&quot;: &quot;divider&quot;,
          &quot;name&quot;: &quot;Foo&quot;
      },
      {
          &quot;type&quot;: &quot;type-b&quot;,
          &quot;name&quot;: &quot;Foo&quot;
      },
      {
          &quot;type&quot;: &quot;type-b&quot;,
          &quot;name&quot;: &quot;Foo&quot;
      },
      {
          &quot;type&quot;: &quot;divider&quot;,
          &quot;name&quot;: &quot;Foo&quot;
      },
      {
          &quot;type&quot;: &quot;type-c&quot;,
          &quot;name&quot;: &quot;Foo&quot;
      }
  ]
  </code></pre>
  <p>Desired output:</p>
  <pre><code>[
      [
          {
              &quot;type&quot;: &quot;type-a&quot;,
              &quot;name&quot;: &quot;Foo&quot;
          },
          {
              &quot;type&quot;: &quot;type-b&quot;,
              &quot;name&quot;: &quot;Foo&quot;
          },
          {
              &quot;type&quot;: &quot;type-c&quot;,
              &quot;name&quot;: &quot;Foo&quot;
          }
      ],
      [
          {
              &quot;type&quot;: &quot;type-b&quot;,
              &quot;name&quot;: &quot;Foo&quot;
          },
          {
              &quot;type&quot;: &quot;type-b&quot;,
              &quot;name&quot;: &quot;Foo&quot;
          }
      ],
      [
          {
              &quot;type&quot;: &quot;type-c&quot;,
              &quot;name&quot;: &quot;Foo&quot;
          }
      ]
  ]
  </code></pre>