title: Javascript: Convert dot-delimited strings to nested object value
body: <p>I have a bunch of object attributes coming in as dot-delimited strings like <code>"availability_meta.supplier.price"</code>, and I need to assign a corresponding value to <code>record['availability_meta']['supplier']['price']</code> and so on.</p>
  
  <p>Not everything is 3 levels deep: many are only 1 level deep and many are deeper than 3 levels.</p>
  
  <p>Is there a good way to assign this programmatically in Javascript?  For example, I need:</p>
  
  <pre><code>["foo.bar.baz", 1]  // --&gt; record.foo.bar.baz = 1
  ["qux.qaz", "abc"]  // --&gt; record.qux.qaz = "abc"
  ["foshizzle", 200]  // --&gt; record.foshizzle = 200
  </code></pre>
  
  <p>I imagine I could hack something together, but I don't have any good algorithm in mind so would appreciate suggestions.  I'm using lodash if that's helpful, and open to other libraries that may make quick work of this.</p>
  
  <p><strong>EDIT</strong> this is on the backend and run infrequently, so not necessary to optimize for size, speed, etc. In fact code readability would be a plus here for future devs.</p>
  
  <p><strong>EDIT 2</strong> This is NOT the same as the referenced duplicate.  Namely, I need to be able to do this assignment multiple times for the same object, and the "duplicate" answer will simply overwrite sub-keys each time.  Please reopen!</p>