title: Match whitespace in Javascript regexp by object, created through RegExp constructor
body: <p>Please, look into this code. Why does creating of the same regular expression by different ways (by <strong>/<em>regex</em>/</strong> literal and through <strong>RegExp</strong> constructor) cause different result? Why doesn't the second pattern match the whitespace in the <strong>str</strong>?</p>
  
  <pre><code>var str = " "; 
  
  var pat1 = /\s/;
  document.writeln(pat1.test(str)); // shows "true"
  
  var pat2 = new RegExp("\s");
  document.writeln(pat2.test(str)); // shows "false"
  </code></pre>
  
  <p>Can't find the answer on my question anywhere. Thanks</p>