String.fromCodePoint() builds strings from Unicode code points, correctly handling values above U+FFFF. Includes ASCII, emoji, and comparison to fromCharCode().
Reference
String Methods
Methods available on every JavaScript String instance.
- String.fromCodePoint()
- String.prototype.at()
String.prototype.at() returns the character at an index with negative-index support, making tail-end access cleaner than manual length arithmetic.
- String.prototype.charAt()
String.prototype.charAt() retrieves the character at a given index in a string. Covers syntax, bracket notation comparison, and Unicode caveats.
- String.prototype.charCodeAt()
String.prototype.charCodeAt() returns an integer for the UTF-16 code unit at a specified position in a string, useful for character validation and sorting.
- String.prototype.codePointAt()
String.prototype.codePointAt() returns the Unicode code point at a given position, handling surrogate pairs that charCodeAt() would misrepresent.
- String.prototype.concat()
String.prototype.concat() joins strings into one value in JavaScript. Covers variadic arguments, type coercion, and why template literals are a better option.
- String.prototype.endsWith()
Use String.prototype.endsWith() to check if a string ends with a substring. Covers syntax, edge cases, and file-extension patterns in JavaScript.
- String.prototype.includes()
String.prototype.includes() tests whether a string contains a substring, returning a boolean. An ES6 alternative to indexOf with case-sensitive matching.
- String.prototype.indexOf()
String.prototype.indexOf() searches a string and returns the position of a substring or -1. Covers case sensitivity, edge cases, and comparison with includes().
- String.prototype.isWellFormed()
String.prototype.isWellFormed() returns true if a string contains no lone UTF-16 surrogates, false otherwise. Added in ES2024.
- String.prototype.lastIndexOf()
String.prototype.lastIndexOf() searches a string from the end, returning the index of the last matching substring or -1 when not found.
- String.prototype.localeCompare()
String.prototype.localeCompare() performs locale-aware string comparison, returning a number that indicates sort order for building multilingual applications.
- String.prototype.match()
String.prototype.match() searches strings using regex in JavaScript. Returns match arrays, handles the global flag, and supports capture and named groups.
- String.prototype.matchAll()
String.prototype.matchAll() returns an iterator of regex matches with capture groups, named groups, and positions — all using the global flag in JavaScript.
- String.prototype.normalize()
String.prototype.normalize() returns a Unicode normalization form of a string for comparing text with different character compositions that looks identical.
- String.prototype.padEnd()
String.prototype.padEnd() pads a string to a target length by appending characters to the right. Used for fixed-width column alignment in tables and CLI output.
- String.prototype.padStart()
String.prototype.padStart() pads a string to a target length from the left, ideal for fixed-width alignment. Covers syntax, examples, polyfill, and edge cases.
- String.prototype.repeat()
String.prototype.repeat() returns a new string with the original repeated count times. Handles count limits, edge cases, and common patterns.
- String.prototype.replace()
String.prototype.replace() returns a new string with the first match of a pattern swapped. Supports plain strings, regex, and dynamic callback functions.
- String.prototype.replaceAll()
String.prototype.replaceAll() replaces all occurrences of a substring or pattern in a string, returning a new string with every match substituted.
- String.prototype.search()
String.prototype.search() accepts a regex pattern, searches a string for the first match, and returns its index — or -1 when no match is found.
- String.prototype.slice()
String.prototype.slice() extracts a substring between start and end indices without mutating the original. Negative indices count from the string end.
- String.prototype.split()
String.prototype.split() divides a string into an array of substrings using a separator. Supports string and regex patterns with an optional limit argument.
- String.prototype.startsWith()
The String.prototype.startsWith() checks if a string begins with a specified substring, optionally from a given position. Returns true or false, case-sensitive.
- String.prototype.substring()
Use String.prototype.substring() to extract a portion of a string between two indices. Covers argument swapping, edge cases, and comparison with slice().
- String.prototype.toLowerCase()
String.prototype.toLowerCase() returns a new lowercase string for case-insensitive comparisons and input normalization, leaving the original unchanged.
- String.prototype.toUpperCase()
String.prototype.toUpperCase() returns a new uppercase string for case-insensitive comparisons, constant generation, and locale-aware text processing.
- String.prototype.toWellFormed()
Returns a new string with all lone UTF-16 surrogates replaced by the Unicode replacement character (U+FFFD), so the result is well-formed UTF-16.
- String.prototype.trim()
String.prototype.trim() removes whitespace from both ends of a string, returning a new, cleaned copy while leaving the original unchanged.
- String.prototype.trimEnd()
String.prototype.trimEnd() removes trailing whitespace from a string without modifying the original. Learn syntax, use cases, and how it differs from trim().
- String.prototype.trimStart()
trimStart() removes leading whitespace from a string, returning a new string — ideal for cleaning user input, log entries, and template literal indentation.