List of Javascript string methods.

Checkout the list of Javascript string methods which you can use to for better programming.

String Properties

String.prototype

String.prototype represents the prototype object of the string which can be used to add or extend the methods.

String.length

String.length returns the size of the string. No of characters present in the given string.


String Methods

String.fromCharCode()

String.fromCharCode() is a static method that creates a new string from the UTF-16 code units. The code units should be passed in a specified sequence.

String.from​Code​Point()

String.from​Code​Point() is a static method that creates a new string from the code points. The code points should be passed in a specified sequence.

String​.prototype​.charAt()

String​.prototype​.charAt() returns a new string from the single UTF-16 code unit situated at specific index in the given string.

String​.prototype​.char​CodeAt()

String​.prototype​.char​CodeAt() returns a integer value between 0 and 65535 which is the UTF-16 code unit of the character situated at the specific index in the string.

String​.prototype​.code​PointAt()

String​.prototype​.code​PointAt() returns a positive integer value which represent the Unicode code point value at the given index.

String​.prototype​.concat()

String​.prototype​.concat() joins one or more strings to the current string and returns a new string.

String​.prototype​.ends​With()

String​.prototype​.ends​With() checks if the string ends with the given characters. It returns true or false depending upon the result.

String​.prototype​.includes()

String​.prototype​.includes() checks if the string has the another specified string or character. It returns true or false depending upon the result.

String​.prototype​.indexOf()

String​.prototype​.indexOf() returns the index of the first matching occurrence of the specified string or character. It will return -1 if not found.

String​.prototype​.last​IndexOf()

String​.prototype​.last​IndexOf() returns the index of the last matching occurrence of the specified string or character. It will return -1 if no match is found.

String​.prototype​.locale​Compare()

String​.prototype​.locale​Compare() returns an integer indicating whether specified string is before, after or same as the given string in sort order. 1 if it is greater, -1 if it is lesser, 0 if it is same.

String​.prototype​.match()

String​.prototype​.match() returns an array of matching string with a regular expression.

String​.prototype​.matchAll()

String​.prototype​.matchAll() returns an iterator for an array of matching string with a regular expression.

String​.prototype​.normalize()

String​.prototype​.normalize() returns the Unicode Normalization Form of a given string.

String​.prototype​.padEnd()

String​.prototype​.padEnd() adds new string to the end of the given string number of times specified.

String​.prototype​.pad​Start()

String​.prototype​.pad​Start() adds new string to the front of the given string number for the number of times specified.

String​.prototype​.repeat()

String​.prototype​.repeat() creates a new string by repeating the current string to the number of times specified and joining them together.

String​.prototype​.replace()

String​.prototype​.replace() returns a new string with some or all patterns replaced by replacement. The replacement can be a string or a regular expression.

String​.prototype​.search() returns the index of the first match which is matched using regular expression. If no match is found then it will return -1.

String​.prototype​.slice()

String​.prototype​.slice() returns a part of the string as new string without mutating the original string.

String​.prototype​.split()

String​.prototype​.split() returns an array of substring by splitting the string at given expression using regular expression.

String​.prototype​.starts​With()

String​.prototype​.starts​With() checks if the given string start with the specified string or character. It will true or false based on the result.

String​.prototype​.substring()

String​.prototype​.substring() returns part of the string as a substring between the specified start and end index.

String​.prototype​.toLocale​Lower​Case()

String​.prototype​.toLocale​Lower​Case() converts the string to the lowercase according to the locale specified and its case mappings.

String​.prototype​.toLocaleUpperCase()

String​.prototype​.toLocaleUpper​Case() converts the string to the uppercase according to the locale specified and its case mappings.

String​.prototype​.toLower​Case()

String​.prototype​.toLower​Case() converts the string to the lowercase.

String​.prototype​.toUpperCase()

String​.prototype​.toUpperCase() converts the string to the uppercase.

String​.prototype​.toString()

String​.prototype​.toString() returns a string representing the specified object.

String​.prototype​.trim()

String​.prototype​.trim() removes all the whitespace and whitespace characters(space, tab, no-break space, etc) from the string.

String​.prototype​.trimEnd()

String​.prototype​.trimEnd() removes all the whitespace and whitespace characters(space, tab, no-break space, etc) from the end of the given string.

String​.prototype​.trim​Start()

String​.prototype​.trim​Start() removes all the whitespace and whitespace characters(space, tab, no-break space, etc) from the start of the given string.

String​.prototype​.valueOf()

String​.prototype​.valueOf() returns the value of the String object.

String​.prototype​[@@iterator]()

String​.prototype​[@@iterator]() returns an iterator object which will iterate over the code point value of the string.

String​.raw()

String​.raw() method is a tag function of template literals. It’s used to get the raw string form of template strings.

String​.prototype​.toSource()

String​.prototype​.toSource() returns a string representing the source code of the object.


String methods which will be deprecated in future

These javascript string methods are still supported in some older browsers but will be deprecated in the future, so use them carefully.

String​.prototype​.anchor()

String​.prototype​.anchor() method creates an anchor tag <a> with given string as anchor text and passed values as anchor name.

String​.prototype​.big()

String​.prototype​.big() method creates a big tag <big> which displays string in bigger font.

String​.prototype​.blink() method creates a blink tag <blink> which makes the string to blink.

String​.prototype​.bold()

String​.prototype​.bold() method creates a blod tag <b> which makes the string bold.

String​.prototype​.fixed()

String​.prototype​.fixed() method creates a Fixed-pitch tag <tt> which displays the string at fixed font.

String​.prototype​.fontcolor()

String​.prototype​.fontcolor() method creates a Font tag <font> which displays the string in a specified font color.

String​.prototype​.fontsize()

String​.prototype​.fontsize() method creates a Font tag <font> which displays the string in a specified font size.

String​.prototype​.italics()

String​.prototype​.italics() method creates a Italic tag <i> which displays the string as italic.

String​.prototype​.link() method creates an Anchor tag <a> and uses the given string as an anchor text and passed value as the URL.

String​.prototype​.small()

String​.prototype​.small() method creates a Small tag <small> which displays the string in the small font.

String​.prototype​.strike()

String​.prototype​.strike() method creates a Strike tag <strike> which displays the string as struck-out text.

String​.prototype​.sub()

String​.prototype​.sub() method creates a Sub tag <sub> which displays the string as subscript.

String​.prototype​.sup()

String​.prototype​.sup() method creates a Sup tag <sup> which displays the string as superscript.

String​.prototype​.substr()

String​.prototype​.substr() method returns a substring from the start index and no of characters from that index.