Constructor
new MutableString(initialString)
- Source:
Initializes a new instance of the MutableString class.
Parameters:
Name | Type | Description |
---|---|---|
initialString |
string | The initial string to use as the basis for the mutable string. |
Methods
append(str)
- Source:
Appends a string to the end of the mutable string.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | The string to append to the mutable string. |
charAt(index) → {string}
- Source:
Gets the character at a specified index.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | The position of the character to retrieve. |
Returns:
- The character at the specified index.
- Type
- string
clear()
- Source:
Clears all characters from the mutable string by truncating the array.
delete(index)
- Source:
Deletes a character at a specified index.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | The position of the character to delete. |
insert(index, str)
- Source:
Inserts a character or string at a specified index.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | The position to insert the character or string. |
str |
string | The string to insert at the given index. |
length() → {number}
- Source:
Returns the current length of the mutable string.
Returns:
- The length of the mutable string.
- Type
- number
prepend(str)
- Source:
Prepends a string to the beginning of the mutable string.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | The string to prepend to the mutable string. |
removeFromEnd(n) → {string}
- Source:
Removes the last n characters from the mutable string.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | The number of characters to remove from the end. |
Returns:
- The characters that were removed.
- Type
- string
removeFromStart(n) → {string}
- Source:
Removes the first n characters from the mutable string.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | The number of characters to remove from the beginning. |
Returns:
- The characters that were removed.
- Type
- string
replace(target, replacement)
- Source:
Replaces all occurrences of a substring with a new string.
Parameters:
Name | Type | Description |
---|---|---|
target |
string | The substring to replace. |
replacement |
string | The string to replace the target substring with. |
setCharAt(index, char)
- Source:
Sets a character at a specific index.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | The position to set the character. |
char |
string | The character to set. Only the first character is used if a string is passed. |
toString() → {string}
- Source:
Converts the mutable string back to a regular string.
Returns:
- The current string value.
- Type
- string