Why not just the following?
str.replace(str.charAt(0), "h")
String.prototype.replaceAt = function(index, replacement) {
return this.replace(this.charAt(index), replacement)
}
Or, in a slightly less potentially disastrous way of monkey patching…
Object.defineProperty(String.prototype, "replaceAt", {
value: function(index, replacement) {
return this.replace(this.charAt(index), replacement)
}
})