title: How can I perform a str_replace in JavaScript, replacing text in JavaScript?
body: <p>I want to use <code>str_replace</code> or its similar alternative to replace some text in JavaScript.</p>
  <pre><code>var text = &quot;this is some sample text that i want to replace&quot;;
  var new_text = replace_in_javascript(&quot;want&quot;, &quot;dont want&quot;, text);
  document.write(new_text);
  </code></pre>
  <p>should give</p>
  <pre><code>this is some sample text that i dont want to replace
  </code></pre>
  <blockquote>
  <p>If you are going to regex, what are the performance implications in
  comparison to the built in replacement methods.</p>
  </blockquote>