JavaScript String

22 functions

charAtstr.charAt(index)

Returns the character at the specified index.

charCodeAtstr.charCodeAt(index)

Returns the UTF-16 code of the character at the specified index.

concatstr.concat(...strings)

Combines two or more strings and returns a new string.

endsWithstr.endsWith(searchStr, endPos?)

Determines whether a string ends with the characters of a specified string.

includesstr.includes(searchStr, position?)

Determines whether a string contains a specified string.

indexOfstr.indexOf(searchStr, fromIndex?)

Returns the index of the first occurrence of a specified value.

lastIndexOfstr.lastIndexOf(searchStr, fromIndex?)

Returns the index of the last occurrence of a specified value.

matchstr.match(regexp)

Retrieves the result of matching a string against a regular expression.

padEndstr.padEnd(targetLen, padStr?)

Pads the current string with a given string at the end.

padStartstr.padStart(targetLen, padStr?)

Pads the current string with a given string at the beginning.

repeatstr.repeat(count)

Returns a new string with the original string repeated n times.

replacestr.replace(searchFor, replaceWith)

Returns a new string with the first match replaced.

replaceAllstr.replaceAll(searchFor, replaceWith)

Returns a new string with all matches replaced.

slicestr.slice(beginIndex, endIndex?)

Extracts a section of a string and returns it as a new string.

splitstr.split(separator, limit?)

Divides a string into an ordered list of substrings.

startsWithstr.startsWith(searchStr, position?)

Determines whether a string begins with the characters of a specified string.

toLowerCasestr.toLowerCase()

Returns the calling string value converted to lower case.

toUpperCasestr.toUpperCase()

Returns the calling string value converted to upper case.

trimstr.trim()

Removes whitespace from both ends of a string.

trimEndstr.trimEnd()

Removes whitespace from the end of a string.

trimStartstr.trimStart()

Removes whitespace from the beginning of a string.

atstr.at(index)

Returns the character at a given index (supports negative indices).