json filter nested array with javascript

I want to pull with javascript: {“subNav0”, “subNav1”, “subNav2”, “subNav3”, “subNav4”, “subNav5”}.

my json:

 var data = {
   "menus":{
      "GrandparentNav0":{
         "name":"TopNav",
         "items":[
            {
               "name":"ParentNav0",
               "iconClass":"",
               "items":[
                  {
                     "name":"ParentNav1",
                     "iconClass":"",
                     "items":[
                        {
                           "name":"subNav0",
                           "iconClass":""
                        },
                        {
                           "name":"subNav1",
                           "iconClass":""
                        },
                        {
                           "name":"subNav2",
                           "iconClass":""
                        },
                        {
                           "name":"subNav3",
                           "iconClass":""
                        },
                        {
                           "name":"subNav4",
                           "iconClass":""
                        },
                        {
                           "name":"subNav5",
                           "iconClass":""
                        }
                     ]
                  },
                  
               ]
            }
         ]
      }
   },
  
   
};

i know basic filter of an array:

data .forEach(function(o) {
 o.variable = o.variable.filter(s => s.value == value);
 });

I dont know how to get through menus, GrandparentNav0 to pull the subNav(s)

Answer

By “pull the subNav(s)” do you mean like accessing it through something like bracket notation?

let subNavs = data['menus']['GrandparentNav0']['items'][0]['items']

console.log(subNavs)

/* would return
[
  {
    "name": "subNav0",
    "iconClass": ""
  },
  {
    "name": "subNav1",
    "iconClass": ""
  },
  {
    "name": "subNav2",
    "iconClass": ""
  },
  {
    "name": "subNav3",
    "iconClass": ""
  },
  {
    "name": "subNav4",
    "iconClass": ""
  },
  {
    "name": "subNav5",
    "iconClass": ""
  }
]
*/