title: recursive functions in typescript/javascript
body: <p>I am trying to call the following function recursively.</p>
  
  <pre><code> public  getData(key,value){
  
     this.htmlString += '&lt;span style="color:cornflowerblue"&gt;'+key+' &lt;/span&gt;:';
  
      if(value instanceof Object){
        Object.keys(value).forEach(function (keydata) {
          let obj = value[keydata];
          this.getData(keydata,value[keydata]);
  
          console.log(key,obj,obj instanceof Object)
        });
      }else{
        this.htmlString += '&lt;span&gt;'+value+'&lt;/span&gt;';
      }
      return this.htmlString;
    };
  </code></pre>
  
  <p>when i tried to call teh function it was showing an error " Cannot read property 'getData' of undefined. Is there any wrong in the code or any other way to do this.</p>