General - Need tips for reading bracket notations in complex multi-dimensional arrays

Hello, its me again.

I’m having trouble wrapping my head on how to read the bracket notations and identifying the levels without editing the code for my ease of understanding/reading. I get that every time a new array is nested within another array, it’s indented - (it’s just a lot of brackets to read/understand from looking at it).

Using the exercise example (with my /**/ comments) for reference:

let nestedArray = [  /*LEVEL 1*/
/* LEVEL 2 - index 0 \*/
  ['deep'],
  [
/* LEVEL 3 - index 1 */
    ['deeper'], ['deeper'] 
  ],
/* LEVEL 4 - index 2 */
  [
    [
      ['deepest'], ['deepest']
    ],
    [
      [
        ['deepest-est?'] /*LEVEL 5 - nestedArray[2][1][0][0][0] */
      ]
    ]
  ]
];

It wasn’t until I condensed it (see code below), was I able to understand that nestedArray[2][1][0][0][0] = ‘deepest-est?’

let nestedArray = [/*LEVEL 1*/
/* index 0 */
  ['deep'], 
/* index 1 */
  [ ['deeper'], ['deeper'] ],  
/* index 2 */
  [ [ ['deepest'], ['deepest'] ], [ [ ['deepest-est?'] ] ] ]
];

Do you guys have personal tips/tricks for making it easier to read the bracket notations for levels without having to edit the code as i did?? Or is it just something you just eventually pick up with time? How often will we see this if we were in real-life production?

Nesting this deeply and so arbitrarily in an array is kind of absurd, and since there’s no context to the data it’s hard to grok. I think the point of this lesson is to show you that you can access items of arbitrary depth.

I think it’s fair to say that generally in the real world you’ll be working with arrays of uniform depth. Like, say a list of coordinates or something like that.

1 Like

This very much eases my mind, but also a slap in the face, since I spent too much time on this exercise lol. THANK YOU for clarifying!