javascript select first non falsey value shows error with array index
<p>I'm trying to use the syntax of:</p>

<pre><code>someVar = otherVar || ''; 
// set someVar to otherVar, or '' if otherVar is false
</code></pre>

<p>when I turn otherVar into some array key, </p>

<pre><code>someVar = otherVar[1] || ''; // otherVar[1] is undefined.
</code></pre>

<p>i get the error </p>

<blockquote>
  <p>Cannot read property '1' of undefined</p>
</blockquote>

<p>This makes sense since otherVar[1] is undefined...But -</p>

<p><strong>Question</strong>: Is the only way to prevent this, to check if <code>otherVar[1]</code> is truthy before setting <code>someVar</code>? Or can I still use this easy method to do set variables quickly like an if else?</p>

<p>I also tried</p>

<pre><code>someVar = (!!otherVar[1]) ? otherVar[1] : ''; // didn't work either.
</code></pre>

<p>Thanks!</p>
