title: Javascript, how to check if object exists
body: <p>I am making a script in Javascript script that gets a SQL response, then processes it. Basically, I want to check if the username value exists in <code>result[1]</code>. When it checks, it errors out and says that it does not exist. If it does not exist, I want it to return false, not stop the program.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>if (result[1].username != undefined) {
      return true;
  } else {
      return false;
  }
  </code></pre>
  
  <p>I have tried using <code>typeof(result1) == undefined</code>, but it gives me the same error.</p>