title: Replace substring in string with range in JavaScript
body: <p>How can I replace a substring of a string given the starting position and the length?</p>
  
  <p>I was hoping for something like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>var string = "This is a test string";
  string.replace(10, 4, "replacement");
  </code></pre>
  
  <p>so that <code>string</code> would equal</p>
  
  <pre class="lang-js prettyprint-override"><code>"this is a replacement string"
  </code></pre>
  
  <p>..but I can't find anything like that.</p>
  
  <p>Any help appreciated.</p>