title: Handling undefined variables simple conditions in NodeJS
body: <p>Given this function:</p>
  
  <pre><code>var test = function(param1, param2_maybe_not_set) {
    var my_object = {};
    // code here...
  }
  </code></pre>
  
  <p>What's the best, in your opinion?</p>
  
  <pre><code>my_object.new_key = (param2_maybe_not_set === undefined) ? null : param2_maybe_not_set;
  </code></pre>
  
  <p><strong>OR</strong></p>
  
  <pre><code>my_object.new_key = (param2_maybe_not_set === void 0) ? null : param2_maybe_not_set;
  </code></pre>
  
  <p><strong>OR</strong></p>
  
  <pre><code>my_object.new_key = (typeof param2_maybe_not_set === 'undefined') ? null : param2_maybe_not_set;
  </code></pre>
  
  <p>Alternatively, would this shortened expression be correct?</p>
  
  <pre><code>my_object.new_key = param2_maybe_not_set || null;
  </code></pre>
  
  <p>All four methods work (in the NodeJS console at least). Also jsPerf doesn't show a big gap between any of these (<a href="http://jsperf.com/typeof-performance/8" rel="nofollow">http://jsperf.com/typeof-performance/8</a>)</p>
  
  <p>Which one should be used, as a <em>good practice</em>?</p>