The replaceAt() function separates the value of the string
parameter into elements according to the specified separator parameter, and then replaces the element with the
given index with the substring parameter.
Syntax
n = String.replaceAt(string, substring, index,
separator)
Part
Description
n
The string returned from the function
string
A string
substring
A string
index
An integer
separator
A string
Example
var a = String.replaceAt("Visit W3Schools!","I love",0," ");
var b = String.replaceAt("Visit W3Schools!","us!",2," ");
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.