JavaScript Tutorial

JS HomeJS EditorsJS How toJS Basic ProgramJS ConsoleJS VariableJS constJS Data TypesJS StringJS Type CastingJS KeywordsJS OperatorsJS Use StrictJS Escape SequencesJS Comments

JS Control Statements

JS ifJS if elseJS else ifJS BreakJS ContinueJS Switch Case

JS Looping

JS Loop ForJS Loop For InJS Loop WhileJS Loop Do While

JS Array

JS ArrayJS Array One DimensionalJS Array Multi DimensionalJS Array Associative

JS Functions

JS FunctionJS Function SelfJS Function call()JS Function apply()JS Call By ValueJS Call By ReferenceJS Function Closures

JS Scope

JS Scope GlobalJS Scope LocalJS Let

JS File Handling

JS File Handling

JS Error Handling

JS try catchJS throwJS finally

JS Select Particulars

JS getElementByID()JS getElementsByClassName()JS getElementsByTagName()JS getElementsByName()JS querySelector()JS querySelectorAll()

JS Popup

JS alert()JS confirm()JS prompt()

JS Events

JS EventsJS Media EventsJS Mouse EventsJS Keyboard EventsJS Form EventsJS Drag EventsJS Clipboard EventsJS Print EventsJS Animation EventsJS Transition EventsJS Server-Sent EventsJS Touch EventsJS Object Events

JS Methods

JS Array MethodsJS String MethodsJS Math MethodsJS Number MethodsJS Date MethodsJS Element MethodsJS Window MethodsJS Node MethodsJS Document MethodsJS Console MethodsJS Timing MethodsJS Navigator MethodsJS Miscellaneous Methods

JS Properties

JS Array PropertiesJS String PropertiesJS Number PropertiesJS MouseEvent PropertiesJS KeyboardEvent PropertiesJS AnimationEvent PropertiesJS TransitionEvent PropertiesJS Element PropertiesJS Window PropertiesJS Node PropertiesJS Document PropertiesJS Navigator PropertiesJS HashChangeEvent PropertiesJS Miscellaneous Properties

JS Regular Expressions

JS Regexp

JS Cookies

JS Cookies

JS Interview Programs

JS Common ProgramsJS Array ProgramsJS Converter ProgramsJS Star Patterns ProgramJS Number Patterns ProgramJS Alphabet Patterns Program

JS Reference

LEARN JSONLEARN AJAXJS KeycodeMIME TypesASCII Table

JavaScript String Methods

Last Updated:

String Methods Demo

Hints

The above demo uses the following string methods.

  • string.toUpperCase() - to convert a string to uppercase letters.
  • string.toLowerCase() - to convert a string to lowercase letters.
  • string.split() - to split a string into an array of substrings.

List of String Methods

The following table provides a list of all string methods available in JavaScript.

MethodExplanation
charAt() Returns the character at the specified index
charCodeAt() Returns the Unicode of the character at the specified index
concat() Combine two or more strings and returns a new joined strings
endsWith() Checks whether a string ends with the characters of another string.
fromCharCode() Converts Unicode values to characters
includes() Checks whether a string contains the specified characters/string
indexOf() Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found
lastIndexOf() Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found
localeCompare() Compares two strings in the current locale
match() Used to match a regular expression against a string
repeat() Returns a new string with a specified number of copies of an existing string
replace() Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring
search() Executes the search for a match between a regular expression and a specified string
slice() Extracts a section of a string and returns a new string
split() Splits a string into an array of substrings
startsWith() Checks whether a string begins with specified characters
substring() Returns the characters in a string between two indexes into the string
toLocaleLowerCase() Converts a string to lowercase letters, according to the host's locale
toLocaleUpperCase() Converts a string to uppercase letters, according to the host's locale
toLowerCase() Converts a string to lowercase letters
toString() Returns a string representing the specified object
toUpperCase() Converts a string to uppercase letters
trim() Removes whitespace from both ends of a string
valueOf() Returns the primitive value of a String object

Share this Page

Meet the Author