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)?