title: To get index or matching values from Nested Array of values : Javascript/Typescript/Lodash
body: <p>I would like to find the matching values by iterating over each array of object values and also to find the path of the matching value.
  Property to be searched for the value is &quot;subMenu&quot; - It can be either an object or an array of strings.</p>
  <h1>Example Array :</h1>
  <pre><code>  mainArray = [
      {
        name: 'mainMenu1',
        subMenu: [
          {
            name: 'subMenuLevel1',
            subMenu: [
              {
                name: 'subMenuLevel2',
                subMenu: ['AAA', 'BBB'],
              },
              {
                name: 'subMenuLevels',
                subMenu: ['CCC'],
              },
            ],
          },
        ],
      },
      {
        name: 'mainMenu2',
        subMenu: ['MMM'],
      },
    ];
  </code></pre>
  <p>Value to be searched \ Input: AAA</p>
  <p>I want to find where the value &quot;AAA&quot; is presented by traversing through all the subMenu property in the available nested array of objects ?
  If &quot;AAA&quot; matches with any of the subMenu Array values may I know how can I take the path of the value as well like the expected output below.</p>
  <h1>Example Output:</h1>
  <pre><code>level3 = AAA , 
  level2 = subMenuLevel2,
  level1 = subMenuLevel1,
  mainLevel = mainMenu1
  </code></pre>