title: Express, EJS, challenge with testing for undefined
body: <p>I'm creating a simple website with nodejs using the express framework, couchdb for a database and EJS for templating.  There will be times when some of my fields are null or undefined in some of my JSON docs, and I need to handle that.</p>
  
  <pre><code>&lt;% if (typeof test !== 'undefined') { %&gt;
    &lt;p&gt;&lt;%= test %&gt;&lt;/p&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>That bit of code seems to handle the 'test' field being undefined just fine, but the code below throws an error that says 'test is undefined'</p>
  
  <pre><code>&lt;% if (test) { %&gt;
    &lt;p&gt;&lt;%= test %&gt;&lt;/p&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>Why doesn't javascript understand test to be undefined and then just put false in the if clause?</p>