jQuery Data Type How to - Remove character from a string








Question

We would like to know how to remove character from a string.

Answer


<!DOCTYPE html>
<html>
<head>
<script>
var mystring = "jav/test string";
<!--from  w w w.  j  a  v  a 2s .  c om-->
String.prototype.replaceAt = function (index, char) {
    console.log(char.length);
    return this.substr(0, index) + char + this.substr(index + 1);
}
document.writeln(mystring.replaceAt(4, ''))
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: