Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMahmoud 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,160 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,160 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,160 PointsExactly!
Mahmoud Nasser
5,507 PointsAha Thanks a lot i got it