title: Identify unique value in a nested array structure
body: <p>I have a JSON structure as below. So it is a dynamic structure e.g. for some rows, if there are 0 level 3 objects applicable (server logic), it would not have the containing level 2 itself. Similarly if there are 0 level 2 objects applicable, it would not have the entire level 1 object itself.</p>
  <pre><code>&quot;level1&quot;:[
      {
          &quot;id&quot;:&quot;0&quot;,
          &quot;index&quot;:&quot;0&quot;,
          &quot;label&quot;:&quot;Level 1 Label a&quot;,
          &quot;level2&quot;:[
              {
              &quot;id&quot;:&quot;0&quot;,
              &quot;index&quot;:&quot;0&quot;,
              &quot;label&quot;:&quot;Level 2 Label 1a&quot;,
              &quot;level3&quot;:[
                  {&quot;id&quot;:&quot;UniqueId1&quot;,&quot;index&quot;:&quot;0&quot;,&quot;label&quot;:&quot;Level 3 Label 00a&quot;}
              ]
              },
              {
              &quot;id&quot;:&quot;1&quot;,
              &quot;index&quot;:&quot;1&quot;,
              &quot;label&quot;:&quot;Level 2 Label 1b&quot;,
              &quot;level3&quot;:[
                  {&quot;id&quot;:&quot;UniqueId2&quot;,&quot;index&quot;:&quot;0&quot;,&quot;label&quot;:&quot;Level 3 Label 00b&quot;}
              ]
          }]
      },
      {
          &quot;id&quot;:&quot;1&quot;,
          &quot;index&quot;:&quot;1&quot;,
          &quot;label&quot;:&quot;Level 1 Label b&quot;,
          &quot;level2&quot;:[
              {
              &quot;id&quot;:&quot;0&quot;,
              &quot;index&quot;:&quot;0&quot;,
              &quot;label&quot;:&quot;Level 2 Label 2a&quot;,
              &quot;level3&quot;:[
                  {&quot;id&quot;:&quot;UniqueId3&quot;,&quot;index&quot;:&quot;0&quot;,&quot;label&quot;:&quot;Level 3 Label a&quot;}
              ]
              },
              {
              &quot;id&quot;:&quot;1&quot;,
              &quot;index&quot;:&quot;1&quot;,
              &quot;label&quot;:&quot;Level 22 Label&quot;,
              &quot;level3&quot;:[
                  {&quot;id&quot;:&quot;UniqueId3&quot;,&quot;index&quot;:&quot;0&quot;,&quot;label&quot;:&quot;Level 3 Label b&quot;}
              ]
          }]
      }
  ]
  </code></pre>
  <p>Now my question is I need to find a given unique Id (e.g. UniqueId3) in this structure and return a boolean (true/false).
  This unique id, if present, would be always at level 3
  I know one way is I can iterate the array and check. But just wanted to understand if there is a better way.</p>
  <p>Updated code to check;</p>
  <pre><code>resp.forEach((level1) =&gt; {
  level1.groups.forEach((level2subGroup) =&gt; {
  level2subGroup.level3.forEach((level3Item) =&gt; {
  if (level3Item.id === IdToCompare) {alert('match found')}
  })
  })
  })
  </code></pre>