title: Lodash _.set only if object exists
body: <p>I am looking to set inner properties of an object only if they already exist. Lodash <code>_.set</code> will create the whole hierarchy if it does not exist.</p>
  
  <p>Is there an easy way to do this ? (Without and if statement ?)</p>
  
  <p>Snippet below:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const obj = {a: {b: 1}};
  
  _.set(obj, 'a.b', 2);
  
  console.log(obj); // Great !
  
  _.set(obj, 'a.c', 1);
  
  console.log(obj); // Great but not what I want. I would like c not to be set because it does not exist in the first place</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>