JavaScript String Functions

The JavaScript String Objects provides various Functions and Constants / Properties. JavaScript String Functions allows us to perform many functionalities such as String comparison, string search, conversions, extraction, manipulation, case conversions etc.

JavaScript String Properties

The following table will show you the list of Properties or Constants available in JavaScript String Object

JavaScript String PropertiesDescription
constructorIt will return the String Constructor Function
lengthThis property will find the length of a given string
prototypeThis will allow you to add references (Properties and methods) to the object

JavaScript String Functions

The following table will show you the list of JavaScript String Functions available in String Object

JavaScript String FunctionsDescription
chartAt()It returns the Character at specified index position
charCodeAt()It returns the Unicode of the Character at a specified index position
concat()This method will help you to Join more than one string and return the new string
fromCharCode()This JavaScript string function convert the Unicode values to Characters
indexOf()Returns the index position of the first occurrence of a specified string. It will return -1 if the specified string not found
lastIndexOf()This string function in JavaScript returns the index position of the last occurrence of a specified string. It will return -1 if the specified string not found
localeCompare()It will check whether two strings are equivalent in the current locale
match()Search for the specified value and returns the match
replace()This JavaScript string function will search for a specified string and replace it with the new string value
search()Search for a specified string and return the index position of the match. It will return -1 if the specified string not found
slice()Extract the part of a string based on the specified indices
split()It will Split the string into an Array of Substrings based on the separator we specified
substr()This JavaScript string function will extract the characters from a string based on the specified Starting position and length
substring()Extract the characters from a string based on the specified indices
toLocaleLowerCase()It will convert the given string into Lowercase letters, by considering the host environment’s current locale
toLocaleUpperCase()Convert the given string into Uppercase letters, by considering the host environment’s current locale
toLowerCase()It will convert a given string into Lowercase letters
toString()This JS string function will convert the given value into String Object
toUpperCase()Convert the given string into Uppercase letters
trim()It will remove the white spaces from both ends
ValueOf()Returns the primitive value of the String Object

TIP: Please refer String HTML Wrapper Methods article. It helps you to understand the HTML wrapper methods available in JavaScript Programming.