title: Creating Dynamic Keys In Object
body: <p>I am struggling to create dynamic nested keys in javascript. My problem is that I need to have a object like this</p>
  
  <pre><code>{
      "grandGrandFather": 'A',
      "firstGrandFather": {
          name: "AA",
          children: {
              first: 'AAA',
              children: {
                  first: "AAAA"
                  }
              }
          }, 
      "secondGrandFather": {
          name: "AB",
          first: 'ABA',
              children: {
                  first: "ABAA",
                  second: "ABAB"
                  }
              }
          }, 
      "thirdGrandFather": {
          name: "AC",
          children: {
              name: "ACA"
  
              }
          }     
  }
  </code></pre>
  
  <p>Here problem is that I need to fetch these data from somewhere and I need to create these values dynamically. The prop creation begins from the first level and goes upto fourth level. So my question is how can I create dynamic keys in JS. Also I know you can create dynamic keys in JS like this:</p>
  
  <pre><code>var obj = {
      prop1: "a",
      prop2: "b",
     prop3:'c'
  
  }
  obj['prop4'] = 'd';
  </code></pre>
  
  <p>Also I have been successful in creating a props to a level but when I need to stack these I get confused any help would be appreciated. </p>
  
  <p><strong>Further details about above object</strong></p>
  
  <p>In the above object I created I am getting data from database and I need to add <strong>firstGrandFather, secondGrandFather, thirdGrandFather</strong> dynamically. Also I don't know what their children props I need to define would be in the object. Some may have <strong>spouse,age,work</strong> props inside some may not also I don't know how many of these I would get. And these goes on for one or two more level. </p>
  
  <p>In php it would be easy to create these in associative array easily but I am having hard time doing it in JS.</p>