0

Here,I looking to how to counter this "Maximum call stack size exceeded" error,I try to solve this error but I couldn't. In this code I am trying to count numbers in descending order using recursion. Here is my html code:

<html>
<head>
<script src="printInfinity.js" type="text/javascript" asynce></script>
</head>
<body>
</body>
</html>

Here is my JS code:

var i=100000;
function  print() 
{
i-=1;
console.log(i);
if(i!=0)
{
 print();
}

}
print();
Aditya
  • 3
  • 1

1 Answers1

0

You are simply making too many recursive calls and exceed the fixed limits. You can find those limits here: Browser Javascript Stack size limit. Each recursive function call adds one call to the stack and browsers do not handle 100.000 calls.