title: Is there a limit to how many levels you can nest in JavaScript?
body: <p>Say you have this really complex algorithm that requires dozens of for loops.</p>
  
  <p>Does JavaScript have a limit to how deep loops can be nested or is there no limit?</p>
  
  <p>What is the best practice for deep nested for loops?</p>
  
  <p>I tried searching on MDN but couldn't find what I was looking for</p>
  
  <p>Edit</p>
  
  <p>I'm looking if there is a built in limit. For example if you had something like this</p>
  
  <pre><code>If ( a = 1, a &lt; 3, a++) {
      if (b = 1; b &lt; 3; b++) {
          ...
          if (cd = 1; cd &lt; 3; cd++) 
  </code></pre>
  
  <p>Would this actually be possible or would JS throw an error </p>
  
  <p>Edit: Here's a theoretical example of when you might need this</p>
  
  <p>You want to find if any 500 numbers in an array sum up to equal another number. You'd need about 500 loops to add the numbers to a combos array and then filter them to find the sum of them relative to a third number.</p>
  
  <p>Would there even be enough space in the universe to store that much data?</p>