# String ### length number ### at(index) function Return the character (or surrogate pair) at the specified index, with support for negative indices (counting from the end). If the index is out of range, returns undefined. **index**: The position of the character to return (can be negative). **Returns**: A string of length 1 representing the character, or undefined if out of range. ### charCodeAt(index) function Return a number indicating the UTF-16 code unit value at the given index. If the index is out of range, returns NaN. **index**: An integer between 0 and string length - 1. **Returns**: An integer in the range [0, 65535] or NaN if out of range. ### charAt(index) function Return a string consisting of the single UTF-16 code unit at the given index. If the index is out of range, returns an empty string. **index**: The zero-based index of the desired character. **Returns**: The single-character string at the specified index, or '' if out of range. ### concat(stringN) function Concatenate the provided string arguments to the current string and return a new string. **stringN**: One or more strings to concatenate. **Returns**: A new string formed by joining the caller with the provided arguments. ### codePointAt(position) function Return a non-negative integer that is the Unicode code point value at the given position. Supports code points above 0xFFFF. Returns undefined if index is out of range. **position**: The index in the string (can be surrogate pairs). **Returns**: The code point value, or undefined if out of range. ### isWellFormed() function Return a boolean indicating whether the string is valid Unicode. If it contains unpaired surrogate code points, return false. **Returns**: True if the string is well-formed UTF-16, otherwise false. ### toWellFormed() function Return a new string in which any unpaired surrogate code points have been replaced by the Unicode replacement character U+FFFD. **Returns**: A well-formed UTF-16 version of the string. ### indexOf(searchValue, fromIndex) function Return the zero-based index of the first occurrence of 'searchValue' in the string, starting at 'fromIndex'. If not found, return -1. **searchValue**: The substring to search for. **fromIndex**: The index at which to begin searching (default 0). **Returns**: The index of the first match, or -1 if not found. ### lastIndexOf(searchValue, fromIndex) function Return the zero-based index of the last occurrence of 'searchValue' in the string, searching backwards from 'fromIndex'. If not found, return -1. **searchValue**: The substring to search for. **fromIndex**: The index at which to begin the backward search (defaults to string length - 1). **Returns**: The index of the last match, or -1 if not found. ### includes(searchString, position) function Return a boolean indicating whether 'searchString' appears within this string. An optional position can be provided to start searching. **searchString**: The substring to search for. **position**: The position from which to begin searching (default 0). **Returns**: True if the substring is found, otherwise false. ### endsWith(searchString, length) function Return a boolean indicating whether the string ends with 'searchString'. An optional 'length' can be provided to treat the string as if it were only that long. **searchString**: The substring to search for at the end. **length**: An optional length to truncate the string before testing. **Returns**: True if the string ends with 'searchString', otherwise false. ### startsWith(searchString, position) function Return a boolean indicating whether the string begins with 'searchString'. An optional position can be provided to start checking at that index. **searchString**: The substring to search for at the start. **position**: The index in the string to start searching (default 0). **Returns**: True if the string starts with 'searchString', otherwise false. ### match(regexp) function Use a regular expression to match the string. If 'regexp' is not a RegExp, it is converted to one. Return an array of matches or null if none found. **regexp**: The pattern to match (RegExp or string). **Returns**: An array of matches or null. ### matchAll(regexp) function Return an iterator of all RegExp match objects found within the string. If 'regexp' is not a global or sticky RegExp, a TypeError is thrown. **regexp**: The global/sticky RegExp to match over this string. **Returns**: An iterator of match arrays. ### search(regexp) function Use a regular expression to search for a match within the string. Return the index of the first match, or -1 if no match is found. **regexp**: A RegExp or string. If a string, it is converted to RegExp. **Returns**: The index of the first match, or -1 if not found. ### split(separator, limit) function Split the string into an array of substrings using 'separator' (RegExp or string). An optional 'limit' can be provided to limit the number of splits. **separator**: A string or RegExp used to divide the string. **limit**: Maximum number of splits to include in the result array. **Returns**: An array of the split substrings. ### substring(start, end) function Return the substring between 'start' and 'end'. Indices outside the range are clamped. If 'end' < 'start', they swap. **start**: The starting index (0-based). **end**: The ending index (exclusive). **Returns**: The extracted substring. ### substr(start, length) function Return the substring from 'start' for 'length' characters. Negative 'start' counts from the end. This method is deprecated but still supported in many engines. **start**: The starting index. **length**: The number of characters to extract. **Returns**: The extracted substring. ### slice(start, end) function Extract a section of the string from 'start' up to (but not including) 'end', and return it as a new string. Supports negative indices. **start**: The starting index. Negative values count from the end. **end**: The ending index (exclusive). Negative values count from the end. **Returns**: The extracted slice. ### repeat(count) function Construct and return a new string which contains the specified number of copies of the calling string, concatenated together. **count**: The number of times to repeat the string (must be >= 0). **Returns**: A new repeated string. ### replace(searchValue, replaceValue) function Return a new string where the first match (or all matches if 'searchValue' is a global RegExp) of 'searchValue' is replaced by 'replaceValue'. If 'searchValue' is a string, only the first occurrence is replaced. **searchValue**: A string or RegExp to match. **replaceValue**: The replacement string or function. **Returns**: A new string with the matched substring(s) replaced. ### replaceAll(searchValue, replaceValue) function Return a new string where all (non-overlapping) occurrences of 'searchValue' are replaced by 'replaceValue'. If 'searchValue' is a string, each exact match is replaced. **searchValue**: A string or RegExp with the 'g' flag. **replaceValue**: The replacement string or function. **Returns**: A new string with all matches replaced. ### padEnd(maxLength, padString) function Pad the string from the end with the given 'padString' so its length reaches 'maxLength'. The result is a new string. **maxLength**: The desired length of the resulting string. **padString**: The string to pad with (default ' '). **Returns**: A new string padded at the end. ### padStart(maxLength, padString) function Pad the string from the start with the given 'padString' so its length reaches 'maxLength'. The result is a new string. **maxLength**: The desired length of the resulting string. **padString**: The string to pad with (default ' '). **Returns**: A new string padded at the start. ### trim() function Return a new string with whitespace trimmed from the start and end of this string. **Returns**: The trimmed string. ### trimEnd() function Alias for trimEnd(). Remove trailing whitespace from the string. **Returns**: The string without trailing whitespace. ### trimRight() function Alias for trimEnd(). Remove trailing whitespace from the string. **Returns**: The string without trailing whitespace. ### trimStart() function Alias for trimStart(). Remove leading whitespace from the string. **Returns**: The string without leading whitespace. ### trimLeft() function Alias for trimStart(). Remove leading whitespace from the string. **Returns**: The string without leading whitespace. ### toString() function Return a string representing the specified object (itself). Usually called implicitly. Overrides Object.prototype.toString. **Returns**: The string itself. ### valueOf() function Return the primitive string value of this String object. **Returns**: The primitive string value. ### __quote() function (Non-standard) Return a quoted representation of the string, typically for debug or serialization. Implementation details may vary. **Returns**: A quoted version of the string. ### localeCompare(compareString) function Return a number indicating whether this string is less than, equal to, or greater than 'compareString' in sort order, according to the current locale. **compareString**: The string to compare against. **Returns**: A negative number if less, 0 if the same, or a positive number if greater. ### toLowerCase() function Return a new string with all alphabetic characters converted to lowercase. **Returns**: The lowercase version of this string. ### toUpperCase() function Return a new string with all alphabetic characters converted to uppercase. **Returns**: The uppercase version of this string. ### toLocaleLowerCase() function Return a locale-aware lowercase version of this string, using the host's current locale or the specified locale if supported. **Returns**: The locale-sensitive lowercase string. ### toLocaleUpperCase() function Return a locale-aware uppercase version of this string, using the host's current locale or the specified locale if supported. **Returns**: The locale-sensitive uppercase string. ### anchor(name) function Return a string representing an HTML element with a 'name' attribute set to the current string. **name**: The name attribute for the anchor. **Returns**: An HTML ... string. ### big() function Return a string representing an HTML element containing the current string. **Returns**: An HTML ... string. ### blink() function Return a string representing an HTML element containing the current string (historical, not recommended). **Returns**: An HTML ... string. ### bold() function Return a string representing an HTML element containing the current string in bold. **Returns**: An HTML ... string. ### fixed() function Return a string representing an HTML element containing the current string in fixed-width font. **Returns**: An HTML ... string. ### fontcolor(color) function Return a string representing an HTML element with a 'color' attribute, containing the current string. **color**: The color value for the 'font' element. **Returns**: An HTML ... string. ### fontsize(size) function Return a string representing an HTML element with a 'size' attribute, containing the current string. **size**: The size value for the 'font' element. **Returns**: An HTML ... string. ### italics() function Return a string representing an HTML element containing the current string in italics. **Returns**: An HTML ... string. ### link(url) function Return a string representing an HTML element with an 'href' attribute set to the current string. **url**: The URL for the 'href' attribute. **Returns**: An HTML ... string. ### small() function Return a string representing an HTML element containing the current string. **Returns**: An HTML ... string. ### strike() function Return a string representing an HTML element containing the current string with strike-through. **Returns**: An HTML ... string. ### sub() function Return a string representing an HTML element containing the current string as subscript. **Returns**: An HTML ... string. ### sup() function Return a string representing an HTML element containing the current string as superscript. **Returns**: An HTML ... string. ### rm(index, endidx) function Remove characters from this string between 'index' (inclusive) and 'endidx' (exclusive). If 'endidx' is omitted, it defaults to 'index + 1'. **index**: The starting index to remove. **endidx**: The ending index (exclusive). **Returns**: A new string with the specified characters removed. ### tolast(val) function Return the substring of this string up to the last occurrence of 'val'. If 'val' is not found, the entire string is returned. **val**: The substring to locate from the end. **Returns**: A substring up to the last occurrence of 'val'. ### dir() function Return everything before the last slash ('/') in the string. If no slash is found, return an empty string. **Returns**: The directory portion of the path. ### next(char, from) function Search for the next occurrence of 'char' in this string, starting at 'from'. If 'char' is an array, any of those characters qualifies. Return the matching index, or -1 if none is found. **char**: A character (or array of characters) to locate. **from**: The index to start from. **Returns**: The index of the next occurrence, or -1 if not found. ### prev(char, from, count) function Search for the previous occurrence of 'char' before index 'from'. If 'count' is greater than 1, skip multiple occurrences going backward. Return the found index or 0 if not found. **char**: The character to locate. **from**: The index to start from (defaults to the end of the string). **count**: How many occurrences to skip backward (default 0). **Returns**: The index of the previous occurrence, or 0 if not found. ### strip_ext() function Return the string up to (but not including) the last '.' character. If '.' is not found, the entire string is returned. **Returns**: The string without its last extension. ### ext() function Return the substring after the last '.' in this string. If '.' is not found, return an empty string. **Returns**: The file extension or an empty string. ### up_path() function Go up one directory level from the current path, preserving the file name at the end. **Returns**: A new path string one directory up, with the base filename preserved. ### fromlast(val) function Return the substring that appears after the last occurrence of 'val'. If 'val' is not found, an empty string is returned. **val**: The substring to locate. **Returns**: The substring after the last occurrence of 'val'. ### tofirst(val) function Return the substring from the start of this string up to the first occurrence of 'val' (excluded). If 'val' is not found, the entire string is returned. **val**: The substring to locate. **Returns**: A substring up to the first occurrence of 'val'. ### fromfirst(val) function Return the substring after the first occurrence of 'val'. If 'val' is not found, the entire string is returned. **val**: The substring to locate. **Returns**: The substring after 'val', or the entire string if 'val' not found. ### name() function Return the "name" portion of the path without extension. If no slash is found, it's up to the last '.' in the entire string. If there is a slash, it's from the last slash up to (but not including) the last '.'. **Returns**: The name portion of the path without extension. ### set_name(name) function Set the base name (excluding extension) of the path to 'name', preserving the original directory and extension. **name**: The new name to use. **Returns**: A new path string with the updated name. ### base() function Return the portion of this string after the last '/' character. If no '/' is present, the entire string is returned. **Returns**: The base name of the path. ### updir() function Go up one directory from the current path, removing the last directory name. If the path ends with a slash, remove it first. Then remove the final directory. **Returns**: A new string representing one directory level up.