JavaScript String Methods

Beginner
6 min read
Updated: Nov 2026
49 method guides
Method index

About This Index

This page is the JavaScript String Methods index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.

Learn what a String is on /js/string. Use this page when you need a specific API such as slice(), includes(), or trim().

Beginner path.

Start with slice(), includes(), trim(), and replace()—then browse the rest by category. HTML wrapper methods such as bold() are legacy; prefer document.createElement() in new code.

How to Call a String Method

Instance methods use a dot; a few helpers use String:

JavaScript
const title = "  JavaScript  ";

// Instance (String.prototype)
title.trim();            // "JavaScript"
title.includes("Java");  // true
"Hello".slice(0, 2);     // "He"
"a-b-c".split("-");      // ["a", "b", "c"]

// Static (on String)
String.fromCharCode(65); // "A"
String.fromCodePoint(128512); // "😀"

JavaScript String Methods Table

All method guides in this JavaScript tutorial series (49 tutorials).

HTML Wrapper Methods (Deprecated)

13 methods

Legacy helpers that build HTML strings. Prefer document.createElement() in new code.

MethodDescriptionTutorial
anchor()Deprecated HTML wrapper: returns a string with <a name="..."> markup — prefer document.createElement().Open
big()Deprecated HTML wrapper: returns a string with <big> markup — prefer CSS font-size.Open
blink()Deprecated HTML wrapper: returns a string with <blink> markup — avoid blinking text.Open
bold()Deprecated HTML wrapper: returns a string with <b> markup — prefer createElement or CSS font-weight.Open
fixed()Deprecated HTML wrapper: returns a string with <tt> markup — prefer CSS font-family: monospace.Open
fontcolor()Deprecated HTML wrapper: returns a string with <font color="..."> markup — prefer CSS color.Open
fontsize()Deprecated HTML wrapper: returns a string with <font size="..."> markup — prefer CSS font-size.Open
italics()Deprecated HTML wrapper: returns a string with <i> markup — prefer createElement or CSS font-style.Open
link()Deprecated HTML wrapper: returns a string with <a href="..."> markup — prefer document.createElement("a").Open
small()Deprecated HTML wrapper: returns a string with <small> markup — prefer createElement("small") or CSS font-size.Open
strike()Deprecated HTML wrapper: returns a string with <strike> markup — prefer createElement("s") or createElement("del").Open
sub()Deprecated HTML wrapper: returns a string with <sub> markup — prefer document.createElement("sub").Open
sup()Deprecated HTML wrapper: returns a string with <sup> markup — prefer document.createElement("sup").Open

Character Access

5 methods

Read characters, code units, code points, or iterate the string.

MethodDescriptionTutorial
at()Return the UTF-16 code unit at an index — supports negative offsets from the end (at(-1) is last).Open
charAt()Return the UTF-16 code unit at a zero-based index — out of range returns "" (no negative indexes).Open
charCodeAt()Return the UTF-16 code unit at an index as a number (0–65535) — out of range returns NaN.Open
codePointAt()Return the full Unicode code point at a UTF-16 index — out of range returns undefined (handles emoji).Open
[Symbol.iterator]()Make strings iterable by Unicode code points — powers for...of and spread; surrogate pairs stay together.Open

Unicode & Well-Formed

3 methods

Normalize Unicode forms and detect or repair lone UTF-16 surrogates.

MethodDescriptionTutorial
isWellFormed()Return true if the string has no lone UTF-16 surrogates — useful before encodeURI(); pair with toWellFormed().Open
toWellFormed()Replace lone UTF-16 surrogates with U+FFFD (�) — safe for encodeURI(); pair with isWellFormed().Open
normalize()Return a Unicode Normalization Form (NFC/NFD/NFKC/NFKD) — default NFC; use before comparing lookalike text.Open

Extract & Split

4 methods

Pull out parts of a string or split into arrays.

MethodDescriptionTutorial
slice()Extract a section into a new string — exclusive end index; negatives count from the end.Open
substring()Extract between two indexes (exclusive end) — swaps if start > end; negatives treated as 0.Open
substr()Legacy start+length extractor (deprecated Annex B) — prefer slice(); negative length returns "".Open
split()Divide a string into an array by a string or regex separator — optional limit; capturing groups appear in the result.Open

Transform & Pad

9 methods

Change case, trim whitespace, pad, or repeat text.

MethodDescriptionTutorial
toLowerCase()Convert to lowercase with Unicode default mappings — great for case-insensitive compares; no locales arg.Open
toLocaleLowerCase()Locale-aware lowercase — optional BCP 47 locales; Turkish İ differs from toLowerCase().Open
toLocaleUpperCase()Locale-aware uppercase — optional BCP 47 locales; Turkish i → İ; length may grow (ß → SS).Open
trim()Remove whitespace from both ends — spaces, tabs, newlines; middle spaces kept; pair with trimStart/trimEnd.Open
trimStart()Remove leading whitespace only — keeps trailing spaces; alias trimLeft(); pair with trim/trimEnd.Open
trimEnd()Remove trailing whitespace only — keeps leading spaces; alias trimRight(); pair with trim/trimStart.Open
padStart()Pad the start of a string to a target length — default space filler; great for zero-padding and masks.Open
padEnd()Pad the end of a string to a target length — default space filler; padString repeats or truncates.Open
repeat()Build a new string by concatenating the original count times — RangeError for negative or Infinity.Open

Combine & Replace

2 methods

Join strings or swap matched text for new content.

MethodDescriptionTutorial
replace()Replace the first string match or regex matches — use g for all; support $ groups and replacer functions.Open
replaceAll()Replace every string or global-regex match — TypeError if a RegExp is missing the g flag.Open

Compare & Convert

3 methods

Sort-friendly comparison and primitive conversion.

MethodDescriptionTutorial
localeCompare()Locale-aware string ordering — returns <0 / 0 / >0; optional locales and options (sensitivity, numeric).Open
toString()Return the string primitive — unwraps new String(...); same as valueOf(); TypeError for non-string this.Open
valueOf()Return the string primitive — same as toString(); unwraps new String(...); usually called by the engine.Open

Static Methods

3 methods

Helpers on the String constructor — not called on an instance.

MethodDescriptionTutorial
fromCharCode()Static helper: build a string from UTF-16 code units (0–65535) — pair with charCodeAt(); prefer fromCodePoint() for emoji.Open
fromCodePoint()Static helper: build a string from full Unicode code points (0–0x10FFFF) — emoji in one arg; invalid values throw RangeError.Open
raw()Static template tag: keep escape sequences raw while still evaluating ${} — great for paths and RegExp sources.Open

Frequently Asked Questions

String methods are functions on String.prototype such as slice(), includes(), trim(), replace(), and split(). A few helpers are static and live on String itself: String.fromCharCode(), String.fromCodePoint(), and String.raw().
The String page teaches what a String is—quotes, template literals, immutability, and length. This Methods index lists every method tutorial so you can open slice(), includes(), trim(), and the rest.
Instance methods use a dot on a string: "Hello".slice(0, 2), " hi ".trim(), "JS".includes("J"). Static methods use String: String.fromCharCode(65).
No. Strings are immutable. Methods return a new string, a boolean, a number, or an array. Assign the result if you need to keep it.
If you are new, read JavaScript String first. Then open length on the properties index, and slice(), includes(), trim(), and replace() from the tables below.

Start with slice()

Open the extraction guide—syntax, examples, and FAQs.

slice() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful