title: Escaping Strings in JavaScript
body: <p>Does JavaScript have a built-in function like PHP's <code>addslashes</code> (or <code>addcslashes</code>) function to add backslashes to characters that need escaping in a string?</p>
  
  <p>For example, this:</p>
  
  <blockquote>
    <p>This is a demo string with
    'single-quotes' and "double-quotes".</p>
  </blockquote>
  
  <p>...would become:</p>
  
  <blockquote>
    <p>This is a demo string with
    \'single-quotes\' and
    \"double-quotes\".</p>
  </blockquote>