2021年3月4日星期四

How do I iterate through nested arrays the amount of nesting is variable? JS [duplicate]

Given the input array such as this;

var input = [1, 2, [3, 4, [5, 6]], [7, 8]]

How would I be able to pull all the numbers out in a function given the amount of nesting may change based on input? The challenge is to access via index.

https://stackoverflow.com/questions/66485293/how-do-i-iterate-through-nested-arrays-the-amount-of-nesting-is-variable-js March 05, 2021 at 09:06AM

没有评论:

发表评论