JavaScript String Methods | Programiz D11 Phase 2 Skip to main content

JavaScript String Methods

In JavaScript, strings are used to represent and work with a sequence of characters. A string can represent an object as well as the primitive data type. JavaScript automatically converts primitive strings to String objects so that it's possible to use String methods and access properties even for primitive strings.

In this reference page, you will find all String methods and properties available in JavaScript. For example, the toUpperCase() method returns the string converted to uppercase.

Returns the number of characters in a string

replace a substring/pattern in the string

Returns the first index of occurrence of a value

Returns the last index of occurrence of a value

Checks if a string begins with a specified string

Checks if a string ends with a specified string

Returns uppercase of a string

Returns lowercase representation of a string

Checks if given string is found inside a string

Returns a string by repeating it given times

Returns character at a specified index in string

Returns Unicode of the character at given index

Returns a string from the given UTF-16 code units

Returns a specified part of the string

Pads a string at the start to a given length

Pads a string at the end to a given length

Returns the Unicode point value at given index

Returns a string using the given code points

Returns result of matching string with a regex

Returns iterator of results matching with a regex

Compares two strings in the current locale

Searches for specified value in the string

Returns string by replacing all matching patterns

Concatenates the arguments to the calling string

Returns the string divided into list of substring

Removes whitespace from both ends of a string

Extracts and returns a section of the string