0

I have a recursive method like this:

PrintRecursive = function (arr, level) {
    for (var key in arr) {
        var term = arr[key];
        htmlArr.push("<li><input type=\"radio\" name=\"tempName\" id=\"" + term.Id + "\" data-taxonomy-url=\"" + term.Url + "\" /><label for=\"" + term.Id + "\">" + term.Title + "</label>");
        if (term.ChildTerms !== undefined && term.ChildTerms != null) {
            htmlArr.push("<ul>");
            PrintRecursive(term.ChildTerms, ++level);
            level--;
            htmlArr.push("</ul>");
            htmlArr.push("</li>");
        }
        else {
            htmlArr.push("</li>");
        }
    }
}

it generates Out of stack space in IE and Maximum call stack size exceeded in Chrome when it tries to execute htmlArr.push. arr is an array of arrays but total number of items in arr are 385 items. Do I get this error becuase I used recursive method which is being called too many times? or because htmlArr contains too much data (html)?

user217648
  • 3,338
  • 9
  • 37
  • 61

1 Answers1

1

This means your recursive function hits browser's specific call stack limit.

To fix it and for more informations Take a look at following post: Maximum call stack size exceeded error

Community
  • 1
  • 1
ihkawiss
  • 986
  • 3
  • 9
  • 25