title: Javascript: use either a variable, or if it's undefined, a default string
body: <p>I have this code:</p>
  
  <pre><code>var phrase = function (variable, defaultPhrase) {
      if (typeof variable === "undefined") {
          return defaultPhrase;
      }
      else {
          return variable;
      }
  }
  </code></pre>
  
  <p>It's called like this:</p>
  
  <pre><code>Ext.Msg.show({title: phrase(js_shutdown,'Shutdown'), //...
  </code></pre>
  
  <p>What I want to do is to use a default phrase when the variable is not defined, but when I pass an undefined variable to <code>phrase()</code>, JS throws an undefined variable error. How do I fix this? Any other ideas to do this?</p>