I have a data array structured in the following pattern
data = [
[0,
[
['a', [{}, ..., {}]],
['b', [{}, ..., {}]]
]
],
[1,
[
['a', [{}, ..., {}]],
['b', [{}, ..., {}]]
]
],
.
.
.
]
I am attempting to find the length of the innermost arrays of objects. My current approach is as follows:
foo = ([,[[,objects]]]) => console.log(objects.length);
data.foreach(foo);
Despite my expectation, instead of printing the length of each innermost array of objects, I am only getting multiple '1's printed to the console. It appears that objects
is treated as an array with a single element rather than the entire array.
Is there a way to correct this issue while maintaining this specific pattern?
Additionally, is this method of accessing values known as destructuring in JavaScript?