title: Not getting all the keys of nested object using Javascript
body: <p>I am trying to fetch all the keys of one nested object using Javascript but as per my code its not working as expected. I am explaining my code below.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let jsonObj = {
      "service":[
          {
              "name":"restservice",
              "device":"xr-1",
              "interface-port":"0/0/2/3",
              "interface-description":"uBot testing for NSO REST",
              "addr":"10.10.1.3/24",
              "mtu":1024
          }
      ],
      "person": {
      "male": {
        "name": "infinitbility"
      },
      "female": {
        "name": "aguidehub"
      }
    }
  }
  
  const getNestedKeys = (data, keys) =&gt; {
    if(!(data instanceof Array) &amp;&amp; typeof data == 'object'){
      Object.keys(data).forEach(key =&gt; {
        keys.push(key);
        const value = data[key];
        if(typeof value === 'object' &amp;&amp; !(value instanceof Array)){
           getNestedKeys(value, keys);
        }
     });
    }
    return keys
  }
  let result = getNestedKeys(jsonObj, []);
  
  console.log('result', result);</code></pre>
  </div>
  </div>
  </p>
  <p>Here I am not getting the keys present inside the <code>service</code> array. I need to search all the keys present inside one nested object using Javascript.</p>