JS if not a variable
<p>so I want to write a function that takes 3 parameters, 3rd one being optional. I want something to check that if optional does not exist then give it a default value. IS there a IF Not way of doing it? if not then whats the best way of doing it?</p>

<p>This is what i want</p>

<pre><code>foo.(x,y, opt){
if (!opt){opt = 1;}
......
...... 
}
</code></pre>

<p>This is what I have:</p>

<pre><code>foo.(x,y, opt){
if (opt){}
else {opt = 1;};
......
...... 
}
</code></pre>
