title: Node.js RangeError: Maximum call stack size exceeded
body: <p>I am trying to generate all possible combination of a name from my array <code>productsDeduped</code> and then store the generated combination as <code>productTags</code> array. Here is my code: </p>
  
  <pre><code>//function to generate all possible combinations
  function getCombinations(array) {
      var i,
          result = [];
      for (i = 0; i &lt; array.length; i++) {
          result.push(
              array[i],
              ...getCombinations(array.filter((_, j) =&gt; i !== j)).map(v =&gt; array[i] + " " + v)
          );
      }
  
      return result;
  }
  
  for (var i = 0; i &lt; arrLength; i++) {
      var productNameStrings = getCombinations(productsDeduped[i].tags);
  
      productsDeduped[i].productTags = productNameStrings   
  }
  </code></pre>
  
  <p>I get this error: </p>
  
  <pre><code>          result.push(
             ^
  
  RangeError: Maximum call stack size exceeded
      at getCombinations (/Users/farhadam/Silobee/Inventory/categories/execute.js:1006:16)
      at Object.&lt;anonymous&gt; (/Users/farhadam/Silobee/Inventory/categories/execute.js:1016:30)
      at Module._compile (internal/modules/cjs/loader.js:1156:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
      at Module.load (internal/modules/cjs/loader.js:1000:32)
      at Function.Module._load (internal/modules/cjs/loader.js:899:14)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
  </code></pre>
  
  <p>Any idea how I can fix this; I assume its because of the high volume of request?</p>
  
  <p><strong>EDIT:</strong>
  I just looked deeper and when I limit my <code>productNameStrings</code> array of strings to only 9 elements the code works no problem; but if it has 10 or more strings in the array it starts giving me this error! Still dont know how to fix it.</p>