title: JavaScript: Change data in JSON by string data path
body: <p>Let's say, I have the following JSON, which can be easily converted back and forth to a JavaScript object:</p>
  
  <pre><code>{
      "foo": {
          "bar": "Common substitute word",
          "baz": "Another common substitute word",
          "questionWords": {
              "wat": "Inadequate question word",
              "wut": "Even more inadequate question word"
          }
      }
  }
  </code></pre>
  
  <p>And I receive <strong>modifications</strong> regarding this JSON in another JSON file, like this:</p>
  
  <pre><code>{
      "foo.questionWords.wut": "A question word to avoid"
  }
  </code></pre>
  
  <p>So <strong>the path to modify is <em>given as a string</em></strong>. And I have to modify the first JSON by the new data.</p>
  
  <p>But also <strong>the new data path <em>possibly</em> does not exist:</strong></p>
  
  <pre><code>{
      "foo.callingWords.dude": "Commonly used synonym for pal"
  }
  </code></pre>
  
  <p>And the new data path might have <strong>indeterminable depth</strong>:</p>
  
  <pre><code>{
      "who.knows.how.deep.we.will.go": "Look, a penny!"
  }
  </code></pre>
  
  <p>What is the best way to handle this without a JS library, just by plain Vanilia JS?</p>
  
  <p>(You can use the latest JavaScript features.)</p>
  
  <p>Thank you for your help!</p>