How can I replace a substring of a string given the starting position and the length?
I was hoping for something like this:
var string = "This is a test string";
string.replace(10, 4, "replacement");
so that string would equal
"this is a replacement string"
..but I can’t find anything like that.
Any help appreciated.
Like this:
You can add it to the string’s prototype:
(I call this
splicebecause it is very similar to the Array function of the same name)