Created
August 28, 2016 14:56
-
-
Save mahmoud-samy/7e8826d8d68c29263f6f7e8ce84ac866 to your computer and use it in GitHub Desktop.
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
// 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? | |
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