title: Javascript reflection: Get nested objects path
body: <p>In this stackoverflow thread, i learnt you can get a object path via a simple string.</p>
  
  <p><a href="https://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-with-string-key">Accessing nested JavaScript objects with string key</a></p>
  
  <p>consider the following:</p>
  
  <pre><code>var person = { name: "somename", personal: { weight: "150", color: "dark" }};
  
  var personWeight = deep_value(person,"personal.weight");
  </code></pre>
  
  <p>I an trying to construct an array of the object values who are not of type 'object' from my 'person' object.</p>
  
  <p>Hence the array would look like:</p>
  
  <pre><code>[['name', []],['personal.weight', []],['personal.color', []]];
  </code></pre>
  
  <p>I want them to look in that form because i have further use for it down the road.</p>
  
  <p>That's what I've tried:</p>
  
  <pre><code>var toIterate = { name: "somename", personal: { age: "19", color: "dark" } }
  
  var myArray = [];
  
  $.each(toIterate, recursive);
  
  function recursive(key, value) {         
  
      if (key !== null) {
          myArray.push([key, []]);
      }
      else {
          $.each(value, recursive);
      }
  }
  
  console.log(myArray);
  </code></pre>