title: Why do regex constructors need to be double escaped?
body: <p>In the regex below, <code>\s</code> denotes a space character.  I imagine the regex parser, is going through the string and sees <code>\</code> and knows that the next character is special.</p>
  
  <p>But this is not the case as double escapes are required.</p>
  
  <p>Why is this?</p>
  
  <pre><code>var res = new RegExp('(\\s|^)' + foo).test(moo);
  </code></pre>
  
  <p>Is there a concrete example of how a single escape could be mis-interpreted as something else?</p>