title: Is there a JavaScript idiom to change "undefined" to "null"?
body: <p>There's quite a few JavaScript idioms that coerce between types and similar things.</p>
  
  <p><code>!</code> can convert anything falsey to boolean <code>true</code>, <code>!!</code> can convert anything falsey to actual boolean <code>false</code>, <code>+</code> can convert <code>true</code>, <code>false</code>, or a string representing a number into an actual number, etc.</p>
  
  <p>Is there something similar that converts <code>undefined</code> to <code>null</code>?</p>
  
  <p>Now I'm using ternary <code>? :</code> but it would be cool to know if I'm missing a useful trick.</p>
  
  <hr>
  
  <p>OK, let me <strong>contrive</strong> an example ...</p>
  
  <pre><code>function callback(value) {
    return value ? format(value) : null;
  }
  </code></pre>
  
  <p><code>callback</code> is called by 3rd party code which sometimes passes <code>undefined</code>.<br>
  The 3rd party code can handle <code>null</code> being passed back, but not <code>undefined</code>. <code>format()</code> is also 3rd party and can't handle being passed either <code>undefined</code> or <code>null</code>.</p>