title: Javascript: new Regexp destroys for loop iterator when string is concatenated
body: <p>I have an object called script. It contains a variable called name that contains a string.</p>
  
  <p>There is also an array that contains multiptle script objects, the array is called scripts. Its size is 5.</p>
  
  <p>I have a for loop where I want to create a new RegExp for each name of the script objects concatenated with "(":</p>
  
  <pre><code>var scriptName;
  for(var i=0; i&lt;scripts.length; i++){
      console.log("i = "+i);
      scriptName = scripts[i].name+"(";
      var newRegex = new RegExp(scriptName, 'g');
  }
  </code></pre>
  
  <p>The problem is that whenever I concatenate scripts[i].name with "(" the for loop stops working. Instead of increamenting i it stops at i=0. Which is weird beacause the for loop still stops instead of looping indefinately.</p>
  
  <p>If I replace </p>
  
  <pre><code>scriptName = scripts[i].name+"(";
  </code></pre>
  
  <p>with </p>
  
  <pre><code>scriptName = scripts[i].name;
  </code></pre>
  
  <p>I get the correct output:
  0, 1, 2, 3, 4</p>
  
  <p>Otherwise I get the output 0 x 5 times</p>