title: How do I check if an element is undefined?
body: <p>I would like to check to see if a particular attribute of a DOM element is undefined - how do I do that?</p>
  
  <p>I tried something like this:</p>
  
  <pre><code>if (marcamillion == undefined) {
      console.log("Marcamillion is an undefined variable.");
  }
  ReferenceError: marcamillion is not defined
  </code></pre>
  
  <p>As you can see, the reference error is telling me that the variable is not defined, but my <code>if</code> check is clearly not working, because it is producing the standard js <code>ReferenceError</code> as opposed to the error message I am looking for in my <code>console.log</code>.</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>Or better yet, if I am trying to determine if the attribute of an element is undefined like this:</p>
  
  <p><code>$(this).attr('value')</code></p>
  
  <p>What would be the best way to determine if that is undefined?</p>