Javascript: declaring a variable before the conditional result?
<p>My javascript is pretty nominal, so when I saw this construction, I was kind of baffled:</p>

<pre><code>var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
shareProxiesPref.disabled = proxyTypePref.value != 1;
</code></pre>

<p>Isn't it better to do an if on proxyTypePref.value, and then declare the var inside the result, only if you need it?</p>

<p>(Incidentally, I also found this form very hard to read in comparison to the normal usage. There were a set of two or three of these conditionals, instead of doing a single if with a block of statements in the result.)</p>

<p><hr /></p>

<p>UPDATE:</p>

<p>The responses were very helpful and asked for more context. The code fragment is from Firefox 3, so you can see the code here:</p>

<p><a href="http://mxr.mozilla.org/firefox/source/browser/components/preferences/connection.js" rel="nofollow">http://mxr.mozilla.org/firefox/source/browser/components/preferences/connection.js</a></p>

<p>Basically, when you look at the "Connect" preferences window in Firefox, clicking the proxy "modes" (radio buttons), causes various form elements to enable|disable.</p>
