I have been mostly programming in Python. And this year, I learned how to do recursion using it.
A really good technique my prof taught me is to use list comprehensions like so:
def list_all(obj):
if not isinstance(obj, list):
return [obj]
else:
return sum([list_all(x) for x in obj], [])
Now that I am using JS more and more instead of Python, I am wondering what are specific built-in functions you can use in the language to help with recursion. I know that list comprehension are deprecated in JavaScript, so obviously I can't use them anymore. Would map or filter be good substitutes for list comprehensions in tackling recursion? If not, then what?