title: How to check undefined variable in a ternary operator?
body: <p>I have an issue with ternary operation:</p>
  
  <pre><code>let a = undefined ? "Defined!" : "Definitely Undefined",
      b = abc ? "Defined!" : "Definitely Undefined", // ReferenceError
      c = (abc !== undefined) ? "Defined!" : "Definitely Undefined", // ReferenceError
      d = (typeof abc !== "undefined") ? "Defined!" : "Definitely Undefined"
  
  // results: a = d = "Definitely Undefined", 
  // while b and c throw ReferenceError when abc is undefined
  </code></pre>
  
  <p>What is the <strong><em>best and short way</em></strong> to check if abc is <code>undefined</code> before accessing its properties as well as assign blank object <code>{}</code> if <code>undefined</code>?</p>
  
  <pre><code>let a = [[best way to check abc]] ? {[abc.label1]: 2, [abc.label2]: 1} : {}
  </code></pre>
  
  <p><strong>PS:</strong> I am currently using <code>(typeof abc !== "undefined")</code> in place of <code>[[best way to check abc]]</code></p>