Correctly way to find some variable with 2 case
<p>I want to find some variable from 2 different element patterns.</p>

<pre><code>var something = $('.class').attr('data-something');

if(typeof something === 'undefined') {
    var something = $('.class').attr('data-another'); 
}

if(typeof something != 'undefined') {
    // do action...
    console.log(something); 
}
</code></pre>

<p>I just want to get some data from attr <code>data-someting="mydata"</code></p>

<p>And if <code>data-someting="mydata"</code> not found so find a data form <code>data-another</code></p>

<p>Then do action....</p>

<p>Im doing right ? or another correctly way to do better ?</p>

<p>Whats about <code>Try Catch</code> ?</p>
