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 trial

JavaScript

I attempted to create an incredibly simple DOM type structure with javascript or least my understanding of a DOM

/***I created this to better understand the structure DOM, 
out of curiosity does anyone know why obj.ary[0].arry[0] returns 
'Object {ary: Array[1]}' I dont understand this [1] ***/
   var obj={
       ary:[
          {ary:[{ary:[3]}
                         ]  
                                              } 
                                                  ]
                                  };

1 Answer

because the value of obj.ary[0].arry[0] is an array that is 1 in length. If you are using something like an alert or other function that prints a string to the screen it doesn't know how to handle the array as a string so it just prints out what it is. If you want to return the value of 3, then you need obj.ary[0].ary[0].ary[0]

ok thanks!