I have a string, let\'s say Hello world and I need to replace the char at index 3. How can I replace a char by specifying a index?
Hello world
var str = \"h
You can extend the string type to include the inset method:
String.prototype.append = function (index,value) { return this.slice(0,index) + value + this.slice(index); }; var s = "New string"; alert(s.append(4,"complete "));
Then you can call the function: