title: Ignoring undefined values in object
body: <p>I made a function in Javascript (Node.js) that saves data to a database. I'm passing an object with different datafields, but it's not certain the object has every data field that the function uses defined.</p>
  
  <pre><code>   var obj = {value1: '1', value2: '2'}
  
     function(obj) {
  
              mongooseDoc = new Doc({
                      value1: obj.value1,
                      value2: obj.value2,
                      value3: obj.value3,
                      value4: obj.value4,
                      value5: obj.value5.value6
              }
  
     }
  </code></pre>
  
  <p>This will give an error because obj.value3 - 6 is undefined. How do you code this so it won't give an error without having to use 3 if statements? Would you have to declare the whole object with all possible values first or is there a cleaner method?</p>
  
  <p>*<em>UPDATE: How could you handle this for value6, when value5 is undefined in this case? *</em> </p>