DEV Community

Discussion on: The JavaScript Call Stack

Collapse
 
efpage profile image
Eckehard

On error conditions, Javascript will stop executing the program. It is usually a good Idea to use try...catch on critical code sections. But is this a good practice to handle stack overflow?

function myRecursion(){
   try{
        myRecursion();
   }
   catch (e) {
      alert('stack overflow');
   }
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
dani8439 profile image
Dani Schuhman

This explains the try/catch much better than I can in regard to the call stack.

softwareengineering.stackexchange....