Looping multidimensional array values

Hi,

I have the following multidimensional array:

var myarray = [
	[val1, val2],
	[val3, val4, val5],
	[val6, val7],
	[val8, val9, val10, val11],
];

I want to have a loop and get values, for example get the values for 2nd element:

val3, val4, val5.

or get the values for 4th element:

val8, val9, val10, val11

How can I do that using a for loop? Thanks for any ideas.

do you want to loop over the whole array (i.e. all leaf elements) or just over all elements of a sub-array?

for the latter:

// all elements of the second array
myarray[1].forEach(function (item, index) {
    // do something
});

The question in general is a little big vague but you can get creative like the example I whipped up quickly in the below fiddle.