Declaring and testing LOCAL variable in if statement
<p>I'm in need to declare a local variable and test for it inside of condition of if statement. I want to be able to do it as it is possible like this, however I need to do it without global scope; is this possible?</p>

<pre><code>notWorkingSofar('#element');
function notWorkingSofar(a) {
   if(!(b=document.getElementById(a.slice(1)))){return b;}
   else{return false;}
}
</code></pre>

<p>I need it to basically do this; however that gives SyntaxError.</p>

<pre><code>notWorkingSofar('#element');
    function notWorkingSofar(a) {
       if(!(**var** b=document.getElementById(a.slice(1)))){return b;}
       else{return false;}
    }
</code></pre>

<p>Is there any other way to access or set local variables, other then by "var variable="? Maybe by function.variable, akin to window.variable... Not sure though. </p>

<p>EDIT: Trying to do it inside a chain of these: (!!(b = document.getElementById(a.slice(1)))?b:[0,])</p>
