Skip to content
Advertisement

How to iterate over all children elements?

How to iterate over all children elements?

I have an array that has an infinite number of nested childrens, how do I output all of them?

JavaScript

I only go through two levels, but there can be as many as you like.

JavaScript

Advertisement

Answer

Make the mapper a named function, and then you’ll be able to call it recursively.

JavaScript
Advertisement