Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Mahmoud Nasser
5,507 PointsTwo Dimenstional Arrays
what does the Array.length property returns in case of 2d arrays i know it returns the length but it is a bit confusing could some one explain please ?
5 Answers

Balazs Peak
46,121 PointsThink of it like this: multi dimensional arrays are actually not multi dimensional, they are just "recursive".
A 2 dimensional array is an array of arrays. A 3 dimensional array is an array of arrays of arrays ... etc.
The length property returns the outer-most dimension's length.

Balazs Peak
46,121 PointsIt will return the length of the first dimension.
I've made a demonstration with a 2 dimensional and a 1 dimansional array, check it out:

Mahmoud Nasser
5,507 Pointsthe first dimension is the row you mean ??

Balazs Peak
46,121 PointsExactly!

Mahmoud Nasser
5,507 PointsAha Thanks a lot i got it