title: JavaScript: RegExp constructor vs RegEx literal
body: <p>I am studying about RegExp but everywhere I can see two syntax</p>
  <pre><code>new RegExp(&quot;[abc]&quot;)
  </code></pre>
  <p>And</p>
  <pre><code>/[abc]/
  </code></pre>
  <p>And if with modifiers then what is the use of additional backslash (<code>\</code>)</p>
  <pre><code>/\[abc]/g
  </code></pre>
  <p>I am not getting any bug with these two but I wonder is there any difference between these two. If yes then what is it and which is best to use?</p>
  <p>I referred <a href="https://stackoverflow.com/questions/7964916/differences-between-javascript-regexp-literal-and-constructor">Differences between Javascript regexp literal and constructor</a> but there I didn't find an explanation of which is best and what the difference is.</p>