You can add this function to string class
String.prototype.insert_at=function(index, string)
{
return this.substr(0, index) + string + this.substr(index);
}
so that you can use it on any string object:
var my_string = "abcd";
my_string.insertAt(1, "XX");