title: Whats the best way to remove a property from nested javascript Object?
body: <p>I have a tree object as below, I am trying to remove the items array property if it's empty. I am not sure on the best approach to do this?</p>
  
  <p>I am thinking of looping through the key, check the property and then remove using <code>delete myJSONObject[prop]</code>... Any thoughts / ideas are welcome?</p>
  
  <pre><code>[{
      text: "TreeRoot",
      items: [{
          text: "Subgroup1",
          items: []
      }, {
          text: "Subgroup2",
          items: []
      }, {
          text: "Subgroup3",
          items: [],
          items: [{
              text: "subgroup5",
              items: [{
                  text: "subgroup6",
                  items: [{
                      text: "subgroup7",
                      items: [{
                          text: "subgroup8",
                          items: []
                      }]
                  }]
              }]
          }]
      }]
  }]
  </code></pre>