Created
September 23, 2020 13:55
-
-
Save orhanveli/0591f4ff99b4535e48eaaf90859d62c1 to your computer and use it in GitHub Desktop.
The following recursive code will cause a stack overflow if the array list is too large. How can you fix this and still retain the recursive pattern?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var list = readHugeList(); | |
var nextListItem = function() { | |
var item = list.pop(); | |
if (item) { | |
// process the list item... | |
nextListItem(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment