title: How to initialize array variable
body: <p>I want to dynamically initialize a variable array in javascript. I keep getting unexpected token illegal token errors.</p>
  
  <p>in my current script, <code>serviceLimit = 10;</code> but it could be changed at any time.</p>
  
  <p>Attempt #1</p>
  
  <pre><code>var jqSvcPhrase = {};
  for(i=1; i&lt;=serviceLimit; i++) {
    jqSvcPhrase[+ i +] = ''; // produces - Uncaught SyntaxError: Unexpected token ]
  }
  </code></pre>
  
  <p>Attempt #2</p>
  
  <pre><code>var jqSvcPhrase = {};
  for(i=1; i&lt;=serviceLimit; i++) {
    jqSvcPhrase\[+ i +\] = ''; // produces - Uncaught SyntaxError: Unexpected token ILLEGAL
  }
  </code></pre>
  
  <p>Attempt #3</p>
  
  <pre><code>var jqSvcPhrase = {};
  for(i=1; i&lt;=serviceLimit; i++) {
    jqSvcPhrase\\[+ i +\\] = ''; // produces - Uncaught SyntaxError: Unexpected token ILLEGAL
  }
  </code></pre>