Declaring Multiple Variables in JavaScript if using same data?
<p>I have seen posts like <a href="http://stackoverflow.com/questions/694102/declaring-multiple-variables-in-javascript">Declaring Multiple Variables in JavaScript</a> that focus on unique variables (and lots of them), but I am looking at lots of non-unique variables, for example I want to do a much larger version of this...</p>

<pre><code>            var rep;
            var state_def, state_MA, state_WY, state_TN = 'joeblow';
            var state_AZ, state_TX = 'moefoe';
            var state_MT, state_OR = 'growmo';
            var state_OK, state_LA = 'billyjoe';
            var state_WA, state_NM, state_MS = 'messytess';
            var state_VA, state_NY = 'slickrick';
            var state_CA = 'icecube';

            //or
            var state_def = state_MA = state_WY = state_TN = 'joeblow';
</code></pre>

<p>Just to understand, I am using a switch like so...</p>

<pre><code>switch (capitalise(data.regionName)) {
                case 'Arizona': rep = state_AZ; break;
                case 'Texas': rep = state_TX; break;
                case 'Montana': rep = state_MT; break;
                case 'Oregon': rep = state_OR; break;
                case 'New Mexico': rep = state_NM; break;
                case 'Mississippi': rep = state_MS; break;
                case 'Oklahoma': rep = state_OK; break;
                case 'Louisiana': rep = state_LA; break;
                case 'Washington': rep = state_WA; break;
                case 'Massachusetts': rep = state_MA; break;
                case 'Wyoming': rep = state_WY; break;
                case 'Tennessee': rep = state_TN; break;
                case 'Virginia': rep = state_VA; break;
                case 'Illinois': rep = state_IL; break;
                case 'Nevada': rep = state_NV; break;
                default: rep = state_def; break;
            };
</code></pre>

<p>This will have several thousand zipcodes as well, so a secondary switch for this. That is why declaring the state (or zip) variable / user association as short as possible is needed. But I also do not want to fall into any pitfalls I might be unaware of. This works right now with the exception of the <code>default: rep = state_def; break;</code> returning as undefined. Also, does not work in IE8.</p>
